N=int(input()) p=[input().split() for _ in range(N)] pa=[a[0] for a in p] pb=[a[1] for a in p] pc=[b for b in pb if b not in pa] for a in pc: print(a)