#include <bits/stdc++.h>
//#include <immintrin.h>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;

#define PI 3.141592653589
#define endl "\n"
#define int long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i = (a); i < (b); ++i)

#define vi vector<int>
#define vpi vector<pair<int, int>>

const int N = 1e5 + 10, NN = 3e5 + 10;
vector<int> a[N];
int k[N], cnt[NN], v[NN], deg[NN];
vector<int> G[NN], G2[NN];
pair<int, int> cmp[NN];



void solve(){
	int n;
	cin >> n;
	int c = 0;
	fr(i, 0, n){
		cin >> k[i];
		a[i].assign(k[i], 0);
		fr(j, 0, k[i]){
			cin >> a[i][j];
			v[c++] = a[i][j];
		}
	}
	sort(v, v + c);
	c = unique(v, v + c) - v;
	fr(i, 0, n)
		fr(j, 0, k[i])
			a[i][j] = lower_bound(v, v + c, a[i][j]) - v + n;
	int m = n + c;
	fr(i, 0, m){
		deg[i] = 0;
		cnt[i] = -1;
		G[i].clear();
		G2[i].clear();
	}
	fr(i, 0, n)
		fr(j, 0, k[i]){
			G[i].push_back(a[i][j]);
			G[a[i][j]].push_back(i);
			deg[i]++, deg[a[i][j]]++;
		}

	fr(i, 0, m) cmp[i] = {deg[i], i};
	fr(i, 0, n)
		fr(j, 0, k[i]){
			int v = a[i][j];
			if(cmp[i] > cmp[v]) G2[i].push_back(v);
			else G2[v].push_back(i);
		}
	fr(i, 0, m){
		for(int j : G2[i]){
			for(int k : G[j]) if(cmp[i] > cmp[k]){
				if(cnt[k] == -1) cnt[k] = j;
				else{
					if(i < n) cout << i + 1 << ' ';
					if(j < n) cout << j + 1 << ' ';
					if(k < n) cout << k + 1 << ' ';
					if(cnt[k] < n) cout << cnt[k] + 1 << ' ';
					cout << endl;
					return;
				}
			}

		}
		for(int j : G2[i]){
			for(int k : G[j]) if(cmp[i] > cmp[k])
				cnt[k] = -1;
		}
	}
	cout << -1 << endl;

}

signed main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    t = 1;
    cin >> t;
    while(t--) {solve();}
    return 0;
}
