#include "bits/stdc++.h"

using namespace std;
typedef vector<int> VI;


#define REP( x,y ) for( int x=0; x<(y); ++x )
#define FORD( x,y,z ) for( int x=y; x>=(z); --x )
#define FOR(x,b,e) for( int x = b; x <= (e); ++x )
#define SIZE(v) (int)v.size()
#define ALL(c) c.begin(),c.end()
#define VAR(v,n) __typeof(n) v=(n)
#define FOREACH(i,c) for( VAR(i,c.begin());i!=c.end();++i )
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
#define WRITE( V ){ FOREACH(it,V) cerr << *it << ", "; cerr << endl; }

#define DEBUG_NOW_AND_HERE true
#define DEBUG(x) if( DEBUG_NOW_AND_HERE ) cerr << #x << ": " << x << endl;


typedef long long LL;

typedef vector<int> VI;
typedef vector< VI > VVI;
typedef vector<VVI> VVVI;

typedef vector<double> VD;
typedef vector< VD > VVD;

typedef vector<bool> VB;
typedef vector< VB > VVB;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;

typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;

template<class _T, class _E>
ostream& operator<<( ostream& str, const pair<_T,_E> & pair){
    str << "(" << pair.first << "," << pair.second << ")";
    return str;
}

template<class _T>
ostream& operator<<( ostream& str, const vector<_T> & vec ){
    int ile = 0;
    str << "{";
    for( auto p : vec ){
        if(ile > 0) str << ", ";
        ile++;
        str << p;
    }
    str << "}";
    return str;
}
/*
void solve(){
    int N, K;
    cin >> N >> K;
    VPII V(N);
    VI H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
        V[i].first = H[i];
        V[i].second = i;
    }
    sort( ALL(V), [](PII a, PII b){return a.first>b.first;} );

    DEBUG(V);

    constexpr int INF = 1e9;
    bool can = true;
    VI h(N,-1);
    for(int i=0; i<N; i++){
        int x = V[i].second;
        int m = INF;
        int M = -1;
        if(x>0 && h[x-1] != -1){
            m = min( h[x-1], m );
            M = max( h[x-1]+K-1,M );
        }
        if(x+1<N && h[x+1] != -1){
            m = min( h[x+1], m );
            M = max( h[x+1]+K-1,M );
        }

        DEBUG(m);
        DEBUG(M);
        if( M == -1 ){
            h[x] = H[x];
            cerr << "placing " << x << " on height " << h[x] << endl;
            continue;
        }

        if( H[x] + 2*K-1 < m || H[x] > M+K-1 ){
            can = false;
            break;
        }
        else{
            h[x] = max( H[x], m-K+1 );
            h[x] = max( h[x], optymalizacja
            )
        }
            cerr << "placing " << x << " on height " << h[x] << endl;
    }

    DEBUG(h);
    DEBUG(H);

    if( h[0] != H[0] || h.back() != H.back() ) can = false;

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int l_zest;
    cin >> l_zest;
    while(l_zest--){
        solve();
    }
    return 0;
}*/




int N;


VI countCycles4(VVI& V ){
    int N = V.size();

    int E = 0;
    for(auto& v : V) E += v.size();
    E >>= 1;
    int sq = sqrt(E);
    sq >>= 2;

    VI large, small;
    VB inLarge(N,false);

    for( int i=0; i<::N; i++ ){

        if( V[i].size() >= sq ){
            large.push_back(i);
            inLarge[i] = true;
        }
        else small.push_back(i);
    }

    // number of cycles with one of the nodes in a large set.
    long long res_large = 0;

    // now check all pairs of large sets.
    VB was(N,false);
    VB to_check(N,true);

    VI order = large;
    order.insert(order.end(), ALL(small));


    /**
     * In this loop we count all cycles, that contain some 'large node'.
     */
    for( int i=0; i<large.size(); i++ ){
        int d = order[i];

        for(int t : V[d]) if(to_check[t]){
            was[t] = true;
        }

        for( int j=i+1; j<::N; j++ ){
            int d2 = order[j];
            int prev = -1;
            for( int t : V[d2] ){
                if( to_check[t] && was[t] ){
                    if(prev != -1){
                        return {d,prev,d2,t};
                    }
                    prev = t;
                }
            }
        }

        for(int t : V[d]) if(to_check[t]) was[t] = false;
        to_check[d] = false;
    }

    // now calculate all cycles with all 4 small nodes

    VVPII cnt(N);
    for( int d : small ){
        for( int i=0; i<V[d].size(); i++ ){
            int t1 = V[d][i];
            if(inLarge[t1]) continue;

            for( int  j=i+1; j<V[d].size(); j++ ){
                int t2 = V[d][j];
                if(inLarge[t2]) continue;

                if(t1<t2) cnt[t1].emplace_back(t2,d);
                else cnt[t2].emplace_back(t1,d);
            }
        }
    }

//    for(int i=0; i<N; i++) sort(ALL(cnt[i]));

    VI prev(N,-1);
    fill(ALL(was),false);

    for( int i=0; i<N; i++ ){
        for( PII p : cnt[i] ){
            int a = p.first;
            if( was[a] ) return {i,p.second, a,prev[a]};
            was[a] = true;
            prev[a] = p.second;
        }
        for(PII p : cnt[i]){
            int a = p.first;
            prev[a] = -1;
            was[a] = false;
        }
    }

    return {};
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);


    int l_zest;
    cin >> l_zest;
    while(l_zest--){

        cin >> N;

        VVI V(N);
        int S = 0;

        for(int i=0; i<N; i++){
            int k;
            cin >> k;
            S += k;
            V[i] = VI(k);
            for(int j=0; j<k; j++) cin >> V[i][j];
        }

        unordered_set<int> zb;
        for(auto & v : V) zb.insert(v.begin(), v.end());

        unordered_map<int,int> mapper;
        int ccc = 0;
        for(auto t : zb) mapper[t] = ccc++;

        VVI W(N+ccc);
        for( int i=0; i<V.size(); i++ ){
            for( int &t : V[i] ){
                t = mapper[t];
                W[i].push_back(N+t);
                W[N+t].push_back(i);
            }
        }

        auto cyc = countCycles4(W);
        if(cyc.empty()) cout << "-1" << endl;
        else{
//            DEBUG(cyc);
            for(int d : cyc) if( d < N ) cout << d+1 << " ";
            cout << endl;
        }


    }

    return 0;
}


### Prompt

Your challenge is to write a cpp solution to the following problem:

You are given n sets of integers. The i-th set contains k_i integers.

Two sets are called similar if they share at least two common elements, i. e. there exist two integers x and y such that x ≠ y, and they both belong to each of the two sets.

Your task is to find two similar sets among the given ones, or report that there is no such pair of sets.

Input

The first line contains a single integer t (1 ≤ t ≤ 50000) — the number of test cases. Then t test cases follow.

The first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) the number of given sets. The following n lines describe the sets. The i-th line starts with an integer k_i (2 ≤ k_i ≤ 10^5) — the number of integers in the i-th set. Then k_i integers a_{i,1}, a_{i,2}, ..., a_{i,k_i} (1 ≤ a_{i,j} ≤ 10^9) follow — the elements of the i-th set. It is guaranteed that all elements in each set are different.

The total number of elements in all sets in all test cases is not greater than 2⋅ 10^5.

Output

For each test case, print the answer on a single line. 

If there is no pair of similar sets, print -1. 

Otherwise, print two different integers — the indices of the similar sets. The sets are numbered from 1 to n in the order they are given in the input. If there are multiple answers, print any of them.

Example

Input


3
4
2 1 10
3 1 3 5
5 5 4 3 2 1
3 10 20 30
3
4 1 2 3 4
4 2 3 4 5
4 3 4 5 6
2
3 1 3 5
3 4 3 2


Output


2 3 
1 2 
-1

### Response

```cpp
#include "bits/stdc++.h"

using namespace std;
typedef vector<int> VI;


#define REP( x,y ) for( int x=0; x<(y); ++x )
#define FORD( x,y,z ) for( int x=y; x>=(z); --x )
#define FOR(x,b,e) for( int x = b; x <= (e); ++x )
#define SIZE(v) (int)v.size()
#define ALL(c) c.begin(),c.end()
#define VAR(v,n) __typeof(n) v=(n)
#define FOREACH(i,c) for( VAR(i,c.begin());i!=c.end();++i )
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
#define WRITE( V ){ FOREACH(it,V) cerr << *it << ", "; cerr << endl; }

#define DEBUG_NOW_AND_HERE true
#define DEBUG(x) if( DEBUG_NOW_AND_HERE ) cerr << #x << ": " << x << endl;


typedef long long LL;

typedef vector<int> VI;
typedef vector< VI > VVI;
typedef vector<VVI> VVVI;

typedef vector<double> VD;
typedef vector< VD > VVD;

typedef vector<bool> VB;
typedef vector< VB > VVB;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;

typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;

template<class _T, class _E>
ostream& operator<<( ostream& str, const pair<_T,_E> & pair){
    str << "(" << pair.first << "," << pair.second << ")";
    return str;
}

template<class _T>
ostream& operator<<( ostream& str, const vector<_T> & vec ){
    int ile = 0;
    str << "{";
    for( auto p : vec ){
        if(ile > 0) str << ", ";
        ile++;
        str << p;
    }
    str << "}";
    return str;
}
/*
void solve(){
    int N, K;
    cin >> N >> K;
    VPII V(N);
    VI H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
        V[i].first = H[i];
        V[i].second = i;
    }
    sort( ALL(V), [](PII a, PII b){return a.first>b.first;} );

    DEBUG(V);

    constexpr int INF = 1e9;
    bool can = true;
    VI h(N,-1);
    for(int i=0; i<N; i++){
        int x = V[i].second;
        int m = INF;
        int M = -1;
        if(x>0 && h[x-1] != -1){
            m = min( h[x-1], m );
            M = max( h[x-1]+K-1,M );
        }
        if(x+1<N && h[x+1] != -1){
            m = min( h[x+1], m );
            M = max( h[x+1]+K-1,M );
        }

        DEBUG(m);
        DEBUG(M);
        if( M == -1 ){
            h[x] = H[x];
            cerr << "placing " << x << " on height " << h[x] << endl;
            continue;
        }

        if( H[x] + 2*K-1 < m || H[x] > M+K-1 ){
            can = false;
            break;
        }
        else{
            h[x] = max( H[x], m-K+1 );
            h[x] = max( h[x], optymalizacja
            )
        }
            cerr << "placing " << x << " on height " << h[x] << endl;
    }

    DEBUG(h);
    DEBUG(H);

    if( h[0] != H[0] || h.back() != H.back() ) can = false;

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int l_zest;
    cin >> l_zest;
    while(l_zest--){
        solve();
    }
    return 0;
}*/




int N;


VI countCycles4(VVI& V ){
    int N = V.size();

    int E = 0;
    for(auto& v : V) E += v.size();
    E >>= 1;
    int sq = sqrt(E);
    sq >>= 2;

    VI large, small;
    VB inLarge(N,false);

    for( int i=0; i<::N; i++ ){

        if( V[i].size() >= sq ){
            large.push_back(i);
            inLarge[i] = true;
        }
        else small.push_back(i);
    }

    // number of cycles with one of the nodes in a large set.
    long long res_large = 0;

    // now check all pairs of large sets.
    VB was(N,false);
    VB to_check(N,true);

    VI order = large;
    order.insert(order.end(), ALL(small));


    /**
     * In this loop we count all cycles, that contain some 'large node'.
     */
    for( int i=0; i<large.size(); i++ ){
        int d = order[i];

        for(int t : V[d]) if(to_check[t]){
            was[t] = true;
        }

        for( int j=i+1; j<::N; j++ ){
            int d2 = order[j];
            int prev = -1;
            for( int t : V[d2] ){
                if( to_check[t] && was[t] ){
                    if(prev != -1){
                        return {d,prev,d2,t};
                    }
                    prev = t;
                }
            }
        }

        for(int t : V[d]) if(to_check[t]) was[t] = false;
        to_check[d] = false;
    }

    // now calculate all cycles with all 4 small nodes

    VVPII cnt(N);
    for( int d : small ){
        for( int i=0; i<V[d].size(); i++ ){
            int t1 = V[d][i];
            if(inLarge[t1]) continue;

            for( int  j=i+1; j<V[d].size(); j++ ){
                int t2 = V[d][j];
                if(inLarge[t2]) continue;

                if(t1<t2) cnt[t1].emplace_back(t2,d);
                else cnt[t2].emplace_back(t1,d);
            }
        }
    }

//    for(int i=0; i<N; i++) sort(ALL(cnt[i]));

    VI prev(N,-1);
    fill(ALL(was),false);

    for( int i=0; i<N; i++ ){
        for( PII p : cnt[i] ){
            int a = p.first;
            if( was[a] ) return {i,p.second, a,prev[a]};
            was[a] = true;
            prev[a] = p.second;
        }
        for(PII p : cnt[i]){
            int a = p.first;
            prev[a] = -1;
            was[a] = false;
        }
    }

    return {};
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);


    int l_zest;
    cin >> l_zest;
    while(l_zest--){

        cin >> N;

        VVI V(N);
        int S = 0;

        for(int i=0; i<N; i++){
            int k;
            cin >> k;
            S += k;
            V[i] = VI(k);
            for(int j=0; j<k; j++) cin >> V[i][j];
        }

        unordered_set<int> zb;
        for(auto & v : V) zb.insert(v.begin(), v.end());

        unordered_map<int,int> mapper;
        int ccc = 0;
        for(auto t : zb) mapper[t] = ccc++;

        VVI W(N+ccc);
        for( int i=0; i<V.size(); i++ ){
            for( int &t : V[i] ){
                t = mapper[t];
                W[i].push_back(N+t);
                W[N+t].push_back(i);
            }
        }

        auto cyc = countCycles4(W);
        if(cyc.empty()) cout << "-1" << endl;
        else{
//            DEBUG(cyc);
            for(int d : cyc) if( d < N ) cout << d+1 << " ";
            cout << endl;
        }


    }

    return 0;
}


```