def main(): n = int(input()) a = [[] for _ in range(n)] for i in range(n): _, *a[i] = map(int, input().split()) a[i] = a[i][::-1] # pop用に逆順にする for i in range(10 ** 5): if a[i % n]: print(a[i % n].pop(), end=" ") if not any(a): # 全員さばけたら終わり exit() if __name__ == "__main__": main()