#include <bits/stdc++.h>
using namespace std;
 
#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl
#define all(v) (v).begin(),(v).end()
 
typedef long long ll;
 
#define rmin(a,b) a = min<ll>(a,b)
#define rmax(a,b) a = max<ll>(a,b)
 
#define fi first
#define se second
 
const int N = 2e5+10;
vector<int> val_to_id[N];
 
ll n;
vector<int> v[N];
int tem[N];
 
int r;
 
bool check(int i, int id){
	int qnt = 0;
	for(auto &val : v[i]) if(tem[val]==id){
		qnt++;
		if(qnt==2) return 1;
	}
	return 0;
}
 
bool checar(int is, int a, int b){
	if(a>b) swap(a,b);
	
	int x = a;
	for(auto &val : v[is]){
		if(val==x){
			if(x==b) return 1;
			x = b;
		}
	}
	return 0;
}
 
struct mymap{
int n;
vector<int> keys, values;
mymap(){}
mymap(vector<int> _keys){
	keys = _keys;
	n = sz(keys);
	sort(all(keys));
	keys.resize(unique(all(keys))-keys.begin());
	n = sz(keys);
	values = vector<int>(n,0); //valores iniciados zerados
	fr(i,n) values[i] = i;
}
 
int &operator[](int key){
	//assert(binary_search(all(keys),key));
	int id = lower_bound(all(keys),key)-keys.begin();
	return values[id];
}
};
 
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	int id = 1;
	
	srand(time(0));
	
	fr(tt,t){
		int soma = 0;
		vector<int> vaux;
		cin >> n;
		fr(i,n){
			int tam; cin >> tam;
			soma+=tam;
			v[i].resize(tam);
			fr(j,tam){
				cin >> v[i][j];
				vaux.push_back(v[i][j]);
			}
		}
		mymap mp(vaux);
		int maxv = sz(mp.keys)-1;
		{
			fr(i,n) fr(j,sz(v[i])) v[i][j] = mp[v[i][j]];
			fr(i,n) sort(all(v[i]));
		}
		
		r = sqrt(soma);
		r = max<ll>(r,1);
		if(r>30) r = 26*r/30;
		
		int i1_ans = -1, i2_ans = -1;
		
		fr(is,n){
			if(i1_ans!=-1) break;
			if(sz(v[is])>r){
				for(auto &val : v[is]) tem[val] = id;
				id++;
				fr(j,n){
					if(is==j) continue;
					if(j>is and sz(v[j])>r) continue;
					if(check(j,id-1)){
						i1_ans = is, i2_ans = j;
						break;
					}
				}
			} else{
				for(auto &val : v[is]) val_to_id[val].push_back(is);
			}
		}
		
		if(i1_ans==-1){
			int v1 = -1, v2 = -1;
			fr(ival,maxv+1){
				for(auto &is : val_to_id[ival]){
					for(auto &val : v[is]){
						if(val>=ival) break;
						if(tem[val]==id){
							v1 = ival, v2 = val;
							break;
						}
						tem[val] = id;
					}
				}
				id++;
				if(v1!=-1) break;
			}
			if(v1!=-1){
				fr(i,n) if(sz(v[i])<=r){
					if(checar(i,v1,v2)){
						if(i1_ans==-1) i1_ans = i;
						else{
							i2_ans = i;
							break;
						}
					}
				}
				assert(i2_ans!=-1);
			}
		}
		
		if(i1_ans!=-1){
			if(i1_ans>i2_ans) swap(i1_ans,i2_ans);
			cout << i1_ans+1 << " " << i2_ans+1 << "\n";
		} else{
			cout << "-1\n";
		}
		
		fr(i,n) v[i].clear();
		fr(i,maxv+1) val_to_id[i].clear();
	}
}
