typedef long long ll; #include using namespace std; int main() { ll n; std::cin >> n; vector> p(n); ll sum = 0; for (int i = 0; i < n; i++) { ll k; std::cin >> k; sum += k; for (int j = 0; j < k; j++) { ll tmp; std::cin >> tmp; p[i].push_back(tmp); } } ll now = 0; while(sum>0){ if(p[now].size()>0){ std::cout << p[now][0]<<" "; p[now].erase(p[now].begin()); sum--; } now++; now%=n; } std::cout << std::endl; }