import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayDeque> all = new ArrayDeque<>(); for (int i = 0; i < n; i++) { int p = sc.nextInt(); if (p == 0) { continue; } ArrayDeque tmp = new ArrayDeque<>(); for (int j = 0; j < p; j++) { tmp.add(sc.nextInt()); } all.add(tmp); } StringBuilder sb = new StringBuilder(); while (all.size() > 0) { ArrayDeque tmp = all.poll(); if (sb.length() > 0) { sb.append(" "); } sb.append(tmp.poll()); if (tmp.size() > 0) { all.add(tmp); } } System.out.println(sb); } }