local n = io.read("*n") local t = {} for i = 1, n do local pi = io.read("*n") for j = 1, pi do local z = io.read("*n") table.insert(t, {z, j * n + i}) end end table.sort(t, function(x, y) return x[2] < y[2] end) local s = {} for i = 1, #t do s[i] = t[i][1] end print(table.concat(s, " "))