N = int(input()) l = [[] for _ in range(2*N)] name = [] for _ in range(N): a,b = map(str,input().split()) if a not in name: name.append(a) if b not in name: name.append(b) for i in range(len(name)): if name[i] == a: n = i if name[i] == b: m = i l[n].append(m) for i in range(len(l)): if i == len(name): break if l[i] == []: print(name[i])