#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cout <<#x<<":"<<x<<endl;
#define dbgpo(x,y) cout<<"("<<x<<","<<y<<")"<<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl '\n'
#define mod 1000000007
// #define int long long
#define vi vector<int>
#define vvi vector<vector<int>>

#define lim 400

bool checkLarge(vvi &s, int cnt) {
    int nSets = s.size();
    vector<bool> f(cnt);
    for(int i=0; i<nSets;i++){
        if(s[i].size()<=lim)
            continue;
        for(auto &x: s[i]) f[x] = true;
        
        for(int j=0;j<nSets;j++){
            if(j==i) continue;
            int cnt = 0;
            for(auto &y: s[j]) cnt +=f[y];
            if(cnt>1){
                cout << i+1 << " " << j+1 << endl;
                return true;
            }
        }
        for(auto &x: s[i]) f[x] = false;
    }
    return false;
} 

void solve() { 

        //Take input and compress!
        int nSets; cin>>nSets;
        vvi s(nSets);
        map<int,int> compressor;
        int cnt = 0;

        for(int i=0;i<nSets;i++) {
            int ni; cin>>ni;            
            s[i].resize(ni);
            for(int j=0;j<ni;j++) {
                int x;cin>>x;
                if(!compressor.count(x))
                    compressor[x] = cnt++;
                s[i][j] = compressor[x];
            }
            sort(s[i].begin(),s[i].end());
        }

        // setIndices[x] -> vector which stores indices of sets where x occurs
        vvi setIndices(cnt);
        for(int i=0;i<nSets;i++)
            if(s[i].size()<=lim)
                for(auto &v: s[i])
                    setIndices[v].pb(i);
        

        vi last(cnt,-1), pos(cnt, -1);

        for(int val=0; val<cnt; val++) {
            for(auto setNo: setIndices[val]) {
                // mark all values of setNo as visited(x)
                for(int j=0; s[setNo][j] < val ; j++){
                    int a = s[setNo][j];
                    if(last[a] == val){
                        cout << pos[a] + 1 << " " << setNo + 1 << endl;
                        return;
                    }
                    last[a] = val;
                    pos[a] = setNo;
                }
            }
        }

        bool check2 = checkLarge(s,cnt);
        if(check2)
            return;
        cout << -1 << endl;

}

signed main() {
    fast;
    int t;
    cin>>t;

    while(t--) {
        solve();

    }

}
