import java.util.*; class Main5{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] p = new int[n][]; int[] nin = new int[n]; int sum = 0; for(int i = 0; i < n; i++){ nin[i] = sc.nextInt(); sum += nin[i]; p[i] = new int[nin[i]]; for(int j = 0; j < nin[i]; j++){ p[i][j] = sc.nextInt(); } } int i = 0; boolean flag = true; while(flag){ flag = false; for(int j = 0; j < n; j++){ if(nin[j] > i){ System.out.print(p[j][i] + " "); flag = true; } } i++; } } }