n | set_inp = input() | n | init1 = input() |
| set_list = [] | | |
| if set_inp: | | |
| set_list.append(set(eval(set_inp))) | | |
| | | |
n | set_inp = input() | n | sets = [] |
| while set_inp: | | if init1: |
| | | sets.append(set(eval(init1))) |
| | | |
| | | cur = input() |
| | | while cur: |
| cur_set = set(eval(set_inp)) | | cur = set(eval(cur)) |
| new_set_list = [] | | new_sets = [] |
| for s in set_list: | | for el in sets: |
| if cur_set.intersection(s): | | if el.intersection(cur): |
| cur_set = s.union(cur_set) | | cur = cur.union(el) |
| else: | | else: |
n | new_set_list.append(s) | n | new_sets.append(el) |
| | | new_sets.append(cur) |
| | | sets = new_sets.copy() |
| | | cur = input() |
| | | |
t | new_set_list.append(cur_set) | t | |
| set_list = new_set_list.copy() | | |
| set_inp = input() | | |
| | | |
| if len(set_list) > 1: | | if len(sets) > 1: |
| print('NO') | | print('NO') |
| else: | | else: |
| print('YES') | | print('YES') |
| | | |