N = int(input()) ans = [] l = [] for _ in range(N): p,*a = map(int,input().split()) l.append(a[::-1]) for _ in range(100): for i in range(N): if l[i]: ans.append(l[i].pop()) print(*ans)