n = int(input()) a = [] for _ in range(n): a_i = list(map(int, input().split())) a.append(a_i[1:]) len_max = 0 for i in range(n): if len_max < len(a[i]): len_max = len(a[i]) ans = [] for _ in range(len_max): for i in range(n): if len(a[i]) != 0: ans.append(a[i].pop(0)) print(*ans)