num_row = int(input().strip()) arr = [[int(x) for x in reversed(input().split(' '))] for _ in range(0, num_row)] ans = [] for lis in arr: lis.pop() for _ in range(0, 101): for lis in arr: if len(lis) > 0: ans.append(lis.pop()) print(' '.join(map(str, ans)))