Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- h, k = list(map(int, input().strip().split(" ")))
- ind = 0
- familias = {}
- for x in range(h):
- relation = input().split(" ")
- if x == 0:
- familias[ind] = [relation[0], relation[2]]
- else:
- for l in range(0, ind+1):
- if relation[0] in familias[l]:
- familias[l].append(relation[2])
- elif relation[2] in familias[l]:
- familias[l].append(relation[0])
- else:
- ind+=1
- break
- familias[ind] = [relation[0], relation[2]]
- print(familias)
- print(ind)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement