N = int(input()) l = [[int(i) for i in input().split()] for _ in range(N)] line = [] for i in range(1, len(l)): for j in range(l[i][0]): line.append([i, j, l[i][j+1]]) line.sort(key=lambda x:(x[1], x[0])) print(" ".join(str(x[2]) for x in line))