import sys P=["0 "]+[l[3:]for l in sys.stdin] while 1:k=[i for i,p in enumerate(P)if all(P[int(j)]=="0"for j in p.split())][0];print k;P[k]="0"