#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int)x.size()

#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define ROF(x, z, y) for(int x = (y-1); x >= (z); x--)
#define F0R(x, z) FOR(x, 0, z)
#define R0F(x, z) ROF(x, 0, z)
#define trav(x, y) for(auto&x:y)

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;}
template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const char nl = '\n';
const int mxN = 2e5 + 10;
const int BLK = 469;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n;
        cin >> n;
        vi k(n);
        vector<vi> a(n);
        map<int, int> comp;
        int CNT = 0;
        F0R(i, n){
            cin >> k[i];
            a[i].resize(k[i]);
            F0R(j, k[i]) {
                cin >> a[i][j];
                comp[a[i][j]] = 0;
            }
        }
        trav(x, comp){
            x.s = CNT++;
            //cout << "CHK " << x.f << ' ' << x.s << nl;
        }
        vector<vi> nums(CNT);
        vi lst(CNT, -1), pos(CNT, -1);
        F0R(i, n){
            F0R(j, k[i]){
                a[i][j] = comp[a[i][j]];
                nums[a[i][j]].pb(i);
            }
        }
        F0R(i, n) sort(all(a[i]));
        vector<bool> active(CNT);
        F0R(cur, CNT){
            trav(i, nums[cur]){
                if(k[i] > BLK) continue;
                for(int j = 0; a[i][j] < cur; j++){
                    //cout << i << ' ' << j << ' ' << a[i][j] << ' ' << lst[a[i][j]] << ' ' << cur << nl;
                    if(lst[a[i][j]]==cur){
                        cout << pos[a[i][j]]+1 << ' ' << i+1 << nl;
                        goto done;
                    }
                    lst[a[i][j]] = cur;
                    pos[a[i][j]] = i;
                }
            }
        }
        F0R(i, n){
            if(k[i] <= BLK) continue;
            F0R(j, k[i]){
                active[a[i][j]] = 1;
            }
            F0R(j, n){
                if(i == j) continue;
                int cnt = 0;
                trav(l, a[j]){
                    cnt += active[l];
                }
                if(cnt >= 2) {
                    cout << i+1 << ' ' << j+1 << nl;
                    goto done;
                }
            }
            F0R(j, k[i]){
                active[a[i][j]] = 0;
            }
        }
        cout << "-1\n";
        done:;
    }

    return 0;
}