use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut l = s.lines(); let n = l.next().unwrap().parse::().unwrap(); let mut v: Vec<_> = l .map(|l| l.split(' ').skip(1).flat_map(str::parse::)) .collect(); let mut a = vec![]; let mut e = 0; while e < n { e = 0; for i in &mut v { if let Some(x) = i.next() { a.push(x); } else { e += 1; } } } println!( "{}", a.iter() .map(|x| x.to_string()) .collect::>() .join(" ") ); }