Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. n, m = map(int, input().split())
  2. pairs = []
  3. for i in range(m):
  4.     a, b = input().split()
  5.     pairs.append(a + b)
  6. triples = []
  7. ans = []
  8. for i in range(n):
  9.     liar = False
  10.     honest = False      
  11.     triple = list(input().split())
  12.     for j in range(3):
  13.         if liar is True:
  14.             break          
  15.         a = triple[j]
  16.         for pair in pairs:
  17.             if liar is True:
  18.                 break
  19.             if pair[1] == a:
  20.                 #print(a)
  21.                 first = pair[0]
  22.                 #print(first)
  23.                 if first in triple:
  24.                     if triple.index(first) > j:
  25.                         liar = True
  26.                         #print('l')
  27.                     else:
  28.                         honest = True
  29.                         #print('h')
  30.                 else:
  31.                     liar = True
  32.                    
  33.        
  34.         if honest is True and liar is False:
  35.             for pair in pairs:
  36.                 if liar is True:
  37.                     break                
  38.                 if pair[0] == a:
  39.                     second = pair[1]
  40.                     if second in triple:
  41.                         if triple.index(second) < j:
  42.                             liar = True
  43.                         else:
  44.                             honest = True
  45.                     else:
  46.                         continue
  47.     #print(liar)
  48.     #print(honest)
  49.     if liar is True:
  50.         ans.append('liar')
  51.     elif honest is True:
  52.         ans.append('honest')
  53. #print(pairs)
  54. for i in ans:
  55.     print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement