#include<bits/stdc++.h>

using namespace std;

#define loop(i, l, r) for(int i = (int) l; i <= (int) r; i++)
#define rloop(i, r, l) for(int i = (int) r; i >= (int) l; i--)

#define vi vector<int> 
#define ii pair<int, int> 
#define eb emplace_back
#define all(x) begin(x), end(x)
#define fi first
#define se second

#define rand rng
#define endl '\n'
#define sp ' '
#define uno_map unordered_map
#define uno_set unordered_set

const int maxN = 2e5 + 5, bl = 400, maxVal = 4e5 + 5;
int tc, N, X, Y; 
vi S[maxN];
int on[maxN];
vector<ii> cor[maxVal];
vi allVal;
int conv(int x)
{
	return lower_bound(all(allVal), x) - begin(allVal) + 1;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> tc;
	loop(t, 1, tc)
	{
		cin >> N;
		loop(i, 1, N) S[i].clear();
		X = Y = -1;
		allVal.clear();
		loop(i, 1, N)
		{
			int deg;
			cin >> deg;
			while(deg--)
			{
				int v;
				cin >> v;
				S[i].eb(v);
				allVal.eb(v);
			}
		}
		sort(all(allVal));
		loop(i, 1, allVal.size()) cor[i].clear();
		loop(i, 1, N) for(int &t: S[i]) t = conv(t);
		loop(i, 1, N)
		{
			if(S[i].size() >= bl)
			{
				for(int t: S[i]) on[t] = 1;
				loop(j, 1, N)
				{
					if(j == i) continue;
					int cnt = 0;
					for(int t: S[j]) cnt += on[t];
					if(cnt >= 2) 
					{
						X = i; 
						Y = j;
						break;
					}
				}
				for(int t: S[i]) on[t] = 0;
				if(X != -1) break;
			}
		}
		if(X != -1)
		{
			cout << X << " " << Y << endl; continue;	
		}
		loop(i, 1, N)
		{
			if(S[i].size() >= bl) continue;
			for(int j: S[i])
			{
				for(int k: S[i])
				{
					if(j >= k) continue;
					cor[j].eb(k, i);
				}
			}
		}
		loop(i, 1, allVal.size())
		{
			for(ii t: cor[i])
			{
				int j = t.fi, sId = t.se;
				if(on[j])
				{
					X = on[j];
					Y = sId;
					break;
				}
				else 
				{
					on[j] = sId;
				}
			}
			for(ii t: cor[i])
			{
				on[t.fi] = 0;
			}
			if(X != -1) break;
		}
		if(X != -1) 
		{
			cout << X << " " << Y << endl; continue;
		}
		cout << -1 << endl;
	}
}