from collections import defaultdict N = int(input()) st = set() st2 = set() ls = [] k = 0 for i in range(N): s, t = input().split() if s not in st: st.add(s) ls.append(s) if t not in st: st.add(t) ls.append(t) st2.add(s) for x in ls: if x not in st2: print(x)