#include using namespace std; int n, m, k, l, s, t, r, p; struct st { int t, pos, id; }; const int maxn = 20005; vector person[maxn]; int now; int len[maxn]; int out[maxn]; vector all; int warning[105][15]; bool cmp(st x, st y) { return x.t < y.t; } int main() { int T; cin >> T; while (T--) { memset(warning, 0, sizeof(warning)); all.clear(); cin >> n; memset(out, 0, sizeof(out)); for (int i = 1; i <= n; i++) { scanf("%d", &len[i]); person[i].clear(); for (int j = 1; j <= len[i]; j++) { st u; scanf("%d %d", &u.t, &u.pos); u.id = i; person[i].push_back(u); all.push_back(u); } } sort(all.begin(), all.end(), cmp); out[1] = 1; for (st u:person[1]) warning[u.t][u.pos] = 1; now = 0; int ss = all.size(); for (int i = 1; i <= 100; i++) { while (now < ss && all[now].t == i) { if (warning[i][all[now].pos] == 1) { if (out[all[now].id] == 0) { out[all[now].id] = 1; for (st u:person[all[now].id]) if (u.t >= i) warning[u.t][u.pos] = 1; } } now++; } } vectorans; for(int i=1;i<=n;i++) if(out[i]) ans.push_back(i); printf("%d",ans[0]); for(int i=1;i