//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")

/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠋⠀⠀⠀⡧⠚⠉⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⣰⠀⠀⠐⠀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠁
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡷⠤⠤⢬⡀⠀⢀⣴⡷⠗⠚⣷⡤⠛⠉⠙⠮⡙⡄⠀⣸
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠤⠔⠒⣒⡏⢀⣀⣀⡀⣿⠉⢅⠀⠐⠉⢠⢓⢤⡀⠀⠀⠀⠈⠂⠀⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠚⠁⠀⢀⣀⣐⣀⠀⠳⡇⠀⠀⠀⠀⠀⠀⢣⠀⡤⠧⢄⡀⠙⡓⢤⠀⠀⠀⠀⣿⢄⠀⠀⢠
⠀⣀⣀⣀⣀⣀⣀⣤⣀⠀⢀⠚⠚⠀⠦⡀⠠⣉⠉⠓⠀⠀⠀⠽⣄⠀⠀⠀⠀⠀⠀⡁⠀⠀⠀⠀⠀⠉⠙⣍⠙⠚⠉⢿⠉⢾
⠀⠈⢦⠠⠖⠂⠀⠀⠀⡳⠉⠁⠀⠀⠀⠀⢢⠀⠓⡀⠀⠀⠀⠀⠀⠑⠦⣒⣀⣀⣴⠜⠙⡛⠲⣀⣀⠀⠀⠁⡙⣄⡀⠘⡀
⠀⠀⠀⠙⢤⡀⠀⠀⣴⠀⠀⡇⠀⠀⠀⠀⠀⠹⡀⠀⢄⠀⠀⢀⠦⢠⠀⠀⠈⣄⠿⡇⢀⢹⠀⠀⠙⣄⣄⣀⠀⠢⠂⠉⢷
⠀⠲⣒⠒⡋⠄⡄⢠⠃⠀⠀⣇⠀⠀⠀⠀⠃⠀⠹⠳⡀⢦⡀⠀⠀⠀⠳⠀⠀⢎⣆⡇⠘⣸⡇⠀⠀⠀⠙⣀⢷⠀⠀⡄⠀⢧
⢤⠀⠀⠓⢤⣤⠤⣼⠀⠀⠀⠸⠀⠀⣄⠀⠀⠀⡀⢳⡉⠙⣞⣀⣄⠀⠀⠻⠀⢇⢘⡮⢢⣦⣧⠀⠀⠀⠀⠈⣯⠹⢦⣧⠀⠀⠳
⠀⣷⠀⠾⡵⣉⠀⣏⠀⠀⠀⠀⠹⠀⠈⠳⠀⠀⠈⣄⡖⠀⠀⣡⣶⢍⣟⠾⢳⢸⠀⠙⠀⡿⣷⣀⣀⣀⠀⡀⢸⠀⠀⠀⠀⠀⠀⠙
⠀⣿⠀⢸⠋⢸⠀⣿⠆⡀⢠⠀⠀⠘⣄⡀⠰⡀⠀⠈⡾⢫⣟⠖⣤⣸⡰⣧⠀⢿⣤⠀⠹⣷⢾⡉⢦⡀
⠀⠘⡦⠏⠀⢸⠀⢿⣦⠈⠀⠀⠀⡠⣅⠳⡀⠻⠆⠀⢹⠀⠈⠀⠈⠻⠿⠁⠀⠈⠀⡂⣇⢿⢦⠀⠦⡀⠀⠛⡭⠀⠀⠀⠀⠀⠀⣠
⠒⣡⢿⠀⠀⠀⡀⠸⡿⡰⠀⠀⡄⠀⢿⠀⠀⣒⣦⣃⠁⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⡟⢹⣆⣯⢿⡢⡀⡉⠉⠀⠀⠀⠀⠀⠀⠀⠙
⠒⠉⠉⣯⠉⠙⢳⢤⡿⠘⡀⢷⠀⠀⣾⠀⣷⢧⠤⢼⠦⢀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢿⠀⣏⢦⠳⢤⣀
⠀⠀⠀⢹⡄⠀⠀⡄⣿⡷⡀⠂⡽⣠⠛⣍⢦⣀⠈⠙⠁⠀⠀⠀⠀⠀⠔⠀⠀⢠⠋⠀⢧⠘⣶⠈⠙⠯⠀⣀⠤⠒⠒⢄
⠀⠀⠀⠀⣿⠀⠀⢻⠃⠀⠈⠀⠉⣄⠙⠋⠃⢻⡟⢮⠀⠀⠀⠀⠀⠀⠀⠀⡴⣁⠖⣩⢞⢦⣝⣟⠛⣉⠝⠊⢉⡀⠀⠀⠈⢄
⠀⠀⠀⠀⠘⣇⠴⢹⢄⠀⠀⠈⠀⠸⡓⠛⢶⡀⣇⠱⡈⠓⡲⡒⠺⡉⠁⠠⣫⢶⣁⠞⠉⠁⣀⣠⣾⠤⡀⠀⣿⢳⣀⡖⠙⢦⢻
⠀⠀⠀⢀⠖⢻⣄⣀⣿⣄⠀⠀⠹⢤⣘⢦⠀⣰⣽⠀⣽⠹⡇⠙⣄⠸⣦⣾⣒⠯⠒⠚⠛⣽⠋⠉⠢⠀⠈⠀⠀⠉⠷⡛⡁⡦⠒⢧
⠀⢀⠞⠀⠀⡟⡴⣚⠿⠑⠗⠄⣀⡇⠀⠀⠀⠳⡇⠀⠿⣀⠷⠒⠉⠀⠈⠙⡄⠀⠀⠀⢠⠷⡀⠀⠀⠀⣰⣄⡄⠀⠀⠙⣦⣾
⡴⠁⠀⠀⠀⡿⣠⢁⠞⣹⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⠳⣀⠀⠀⠀⠀⠈⠙⢿⢝⣯⣍⠒⠐⡛⢓⢤⣯⡆
⠀⠀⠀⠀⠀⠻⡄⠈⠀⡷⠋⠀⠀⠈⠁⡇⠀⠀⠀⠀⠀⡿⠀⠀⠀⠀⠀⠀⣠⢋⠯⢯⠀⠀⡤⢻⠈⡄⠳⠀⣷⡀⠀⡴⡵⣕⣿⡣
⠀⠀⠀⠀⠀⠀⠀⠲⡞⠳⣄⠀⠀⠀⢠⡇⠀⠀⠀⠰⡾⠉⠞⠀⢳⠶⣤⢰⢠⡁⢦⠑⡷⣿⡴⡟⠀⢃⠀⣳⢳⢎⣤⡯⠋⠓⣿⡝
⠀⠀⠀⠀⠀⣠⠚⠉⠳⡀⠈⣷⣄⠀⠈⣻⡀⠀⠀⠀⡏⡅⠀⣤⠉⠑⣬⣿⡟⡈⠀⢹⠭⠥⣿⠥⣽⡭⢓⣉⠧⠳⣿⣿⣟⠲⢤⣷
*/

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

/* abbr */
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define srt(x) sort(all(x))
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define msv(x, v) memset(x, v, sizeof(x))
#define ms(x) memset(x, 0, sizeof(x))
#define mc(x, y) memcpy(x, y, sizeof(y))

/* typedef for long long */

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

/* typedef for other */

typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

/* typedef for point */

//typedef pii point;
//#define x first
//#define y second

/* typedef for vector */

typedef vector<int> vi;
typedef vector<ll> vl;

/* constant number */

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos((long double) - 1.0);
const double EPS = 1e-8;
const int MOD = 1e9 + 7;

template <typename T>
void cmin(T &x, T y) {
    if(y < x)
        x = y;
}

template <typename T>
void cmax(T &x, T y) {
    if(y > x)
        x = y;
}

#define dbg(x) cerr << #x " = " << (x) << endl

ll qpow(ll x, ll n, ll mod = MOD) {
    if(n < 0)
        return 0;
    ll res = 1;
    while(n) {
        if(n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll sq(ll x) {
    return x * x;
}

double sq(double x) {
    return x * x;
}

ll read() {
    ll res = 0;
    char c = getchar();
    while(!isdigit(c))
        c = getchar();
    while(isdigit(c)) {
        res = res * 10 + (c - '0');
        c = getchar();
    }
    return res;
}

int n, sum;
vi x[100005], X;

namespace Solver {

    void InitOnce() {
#ifdef LOCAL
        freopen("A.txt", "r", stdin);
#endif // LOCAL
        int t;
        scanf("%d", &t);
    }

    void Read() {
        int res = scanf("%d", &n);
        if(res == -1)
            exit(0);
        sum = 0;
        X.clear();
        for(int i = 1; i <= n; ++i) {
            x[i].clear();
            int k;
            scanf("%d", &k);
            while(k--) {
                int a;
                scanf("%d", &a);
                x[i].eb(a);
                X.eb(a);
                ++sum;
            }
        }
        uni(X);
        for(int i = 1; i <= n; ++i) {
            int k = x[i].size();
            for(int j = 0; j < k; ++j)
                x[i][j] = lower_bound(all(X), x[i][j]) - X.begin() + 1;
            srt(x[i]);
//            for(int j : x[i])
//                printf("%d ", j);
//            printf("\n");
        }
    }

    bool vis[200005];
    vector<int> Big, Small;
    vector<pii> p[200005];

    void Solve() {
        Big.clear();
        Small.clear();
        int sum2 = X.size();
        for(int i = 1; i <= sum2; ++i) {
            vis[i] = 0;
            p[i].clear();
        }
        int D = pow(1.0 * sum, 0.25);
        for(int i = 1; i <= n; ++i) {
            int k = x[i].size();
            if(k >= D)
                Big.eb(i);
            else
                Small.eb(i);
        }
        for(const int &i : Big) {
            for(const int &j : x[i])
                vis[j] = 1;
            for(const int &i2 : Small) {
                int cnt = 0;
                for(const int &j : x[i2])
                    cnt += vis[j];
                if(cnt >= 2) {
                    printf("%d %d\n", i, i2);
                    return;
                }
            }
            for(const int &j : x[i])
                vis[j] = 0;
        }
        for(const int &i : Big) {
            for(const int &j : x[i])
                vis[j] = 1;
            for(const int &i2 : Big) {
                if(i2 >= i)
                    break;
                int cnt = 0;
                for(const int &j : x[i2])
                    cnt += vis[j];
                if(cnt >= 2) {
                    printf("%d %d\n", i, i2);
                    return;
                }
            }
            for(const int &j : x[i])
                vis[j] = 0;
        }
        for(const int &i : Small) {
            int k = x[i].size();
            for(int j = 0; j < k; ++j) {
                int u = x[i][j];
                for(int j2 = j + 1; j2 < k; ++j2) {
                    int v = x[i][j2];
                    p[u].eb(v, i);
                }
            }
        }
        for(int i = 1; i <= sum2; ++i) {
            srt(p[i]);
            int k = p[i].size();
            for(int j = 1; j < k; ++j) {
                if(p[i][j].first == p[i][j - 1].first) {
                    printf("%d %d\n", p[i][j].second, p[i][j - 1].second);
                    return;
                }
            }
        }
        puts("-1");
    }

}

int main() {
    Solver::InitOnce();
    while(true) {
        Solver::Read();
        Solver::Solve();
    }
    return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")

/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠋⠀⠀⠀⡧⠚⠉⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⣰⠀⠀⠐⠀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠁
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡷⠤⠤⢬⡀⠀⢀⣴⡷⠗⠚⣷⡤⠛⠉⠙⠮⡙⡄⠀⣸
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠤⠔⠒⣒⡏⢀⣀⣀⡀⣿⠉⢅⠀⠐⠉⢠⢓⢤⡀⠀⠀⠀⠈⠂⠀⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠚⠁⠀⢀⣀⣐⣀⠀⠳⡇⠀⠀⠀⠀⠀⠀⢣⠀⡤⠧⢄⡀⠙⡓⢤⠀⠀⠀⠀⣿⢄⠀⠀⢠
⠀⣀⣀⣀⣀⣀⣀⣤⣀⠀⢀⠚⠚⠀⠦⡀⠠⣉⠉⠓⠀⠀⠀⠽⣄⠀⠀⠀⠀⠀⠀⡁⠀⠀⠀⠀⠀⠉⠙⣍⠙⠚⠉⢿⠉⢾
⠀⠈⢦⠠⠖⠂⠀⠀⠀⡳⠉⠁⠀⠀⠀⠀⢢⠀⠓⡀⠀⠀⠀⠀⠀⠑⠦⣒⣀⣀⣴⠜⠙⡛⠲⣀⣀⠀⠀⠁⡙⣄⡀⠘⡀
⠀⠀⠀⠙⢤⡀⠀⠀⣴⠀⠀⡇⠀⠀⠀⠀⠀⠹⡀⠀⢄⠀⠀⢀⠦⢠⠀⠀⠈⣄⠿⡇⢀⢹⠀⠀⠙⣄⣄⣀⠀⠢⠂⠉⢷
⠀⠲⣒⠒⡋⠄⡄⢠⠃⠀⠀⣇⠀⠀⠀⠀⠃⠀⠹⠳⡀⢦⡀⠀⠀⠀⠳⠀⠀⢎⣆⡇⠘⣸⡇⠀⠀⠀⠙⣀⢷⠀⠀⡄⠀⢧
⢤⠀⠀⠓⢤⣤⠤⣼⠀⠀⠀⠸⠀⠀⣄⠀⠀⠀⡀⢳⡉⠙⣞⣀⣄⠀⠀⠻⠀⢇⢘⡮⢢⣦⣧⠀⠀⠀⠀⠈⣯⠹⢦⣧⠀⠀⠳
⠀⣷⠀⠾⡵⣉⠀⣏⠀⠀⠀⠀⠹⠀⠈⠳⠀⠀⠈⣄⡖⠀⠀⣡⣶⢍⣟⠾⢳⢸⠀⠙⠀⡿⣷⣀⣀⣀⠀⡀⢸⠀⠀⠀⠀⠀⠀⠙
⠀⣿⠀⢸⠋⢸⠀⣿⠆⡀⢠⠀⠀⠘⣄⡀⠰⡀⠀⠈⡾⢫⣟⠖⣤⣸⡰⣧⠀⢿⣤⠀⠹⣷⢾⡉⢦⡀
⠀⠘⡦⠏⠀⢸⠀⢿⣦⠈⠀⠀⠀⡠⣅⠳⡀⠻⠆⠀⢹⠀⠈⠀⠈⠻⠿⠁⠀⠈⠀⡂⣇⢿⢦⠀⠦⡀⠀⠛⡭⠀⠀⠀⠀⠀⠀⣠
⠒⣡⢿⠀⠀⠀⡀⠸⡿⡰⠀⠀⡄⠀⢿⠀⠀⣒⣦⣃⠁⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⡟⢹⣆⣯⢿⡢⡀⡉⠉⠀⠀⠀⠀⠀⠀⠀⠙
⠒⠉⠉⣯⠉⠙⢳⢤⡿⠘⡀⢷⠀⠀⣾⠀⣷⢧⠤⢼⠦⢀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢿⠀⣏⢦⠳⢤⣀
⠀⠀⠀⢹⡄⠀⠀⡄⣿⡷⡀⠂⡽⣠⠛⣍⢦⣀⠈⠙⠁⠀⠀⠀⠀⠀⠔⠀⠀⢠⠋⠀⢧⠘⣶⠈⠙⠯⠀⣀⠤⠒⠒⢄
⠀⠀⠀⠀⣿⠀⠀⢻⠃⠀⠈⠀⠉⣄⠙⠋⠃⢻⡟⢮⠀⠀⠀⠀⠀⠀⠀⠀⡴⣁⠖⣩⢞⢦⣝⣟⠛⣉⠝⠊⢉⡀⠀⠀⠈⢄
⠀⠀⠀⠀⠘⣇⠴⢹⢄⠀⠀⠈⠀⠸⡓⠛⢶⡀⣇⠱⡈⠓⡲⡒⠺⡉⠁⠠⣫⢶⣁⠞⠉⠁⣀⣠⣾⠤⡀⠀⣿⢳⣀⡖⠙⢦⢻
⠀⠀⠀⢀⠖⢻⣄⣀⣿⣄⠀⠀⠹⢤⣘⢦⠀⣰⣽⠀⣽⠹⡇⠙⣄⠸⣦⣾⣒⠯⠒⠚⠛⣽⠋⠉⠢⠀⠈⠀⠀⠉⠷⡛⡁⡦⠒⢧
⠀⢀⠞⠀⠀⡟⡴⣚⠿⠑⠗⠄⣀⡇⠀⠀⠀⠳⡇⠀⠿⣀⠷⠒⠉⠀⠈⠙⡄⠀⠀⠀⢠⠷⡀⠀⠀⠀⣰⣄⡄⠀⠀⠙⣦⣾
⡴⠁⠀⠀⠀⡿⣠⢁⠞⣹⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⠳⣀⠀⠀⠀⠀⠈⠙⢿⢝⣯⣍⠒⠐⡛⢓⢤⣯⡆
⠀⠀⠀⠀⠀⠻⡄⠈⠀⡷⠋⠀⠀⠈⠁⡇⠀⠀⠀⠀⠀⡿⠀⠀⠀⠀⠀⠀⣠⢋⠯⢯⠀⠀⡤⢻⠈⡄⠳⠀⣷⡀⠀⡴⡵⣕⣿⡣
⠀⠀⠀⠀⠀⠀⠀⠲⡞⠳⣄⠀⠀⠀⢠⡇⠀⠀⠀⠰⡾⠉⠞⠀⢳⠶⣤⢰⢠⡁⢦⠑⡷⣿⡴⡟⠀⢃⠀⣳⢳⢎⣤⡯⠋⠓⣿⡝
⠀⠀⠀⠀⠀⣠⠚⠉⠳⡀⠈⣷⣄⠀⠈⣻⡀⠀⠀⠀⡏⡅⠀⣤⠉⠑⣬⣿⡟⡈⠀⢹⠭⠥⣿⠥⣽⡭⢓⣉⠧⠳⣿⣿⣟⠲⢤⣷
*/

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

/* abbr */
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define srt(x) sort(all(x))
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define msv(x, v) memset(x, v, sizeof(x))
#define ms(x) memset(x, 0, sizeof(x))
#define mc(x, y) memcpy(x, y, sizeof(y))

/* typedef for long long */

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

/* typedef for other */

typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

/* typedef for point */

//typedef pii point;
//#define x first
//#define y second

/* typedef for vector */

typedef vector<int> vi;
typedef vector<ll> vl;

/* constant number */

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos((long double) - 1.0);
const double EPS = 1e-8;
const int MOD = 1e9 + 7;

template <typename T>
void cmin(T &x, T y) {
    if(y < x)
        x = y;
}

template <typename T>
void cmax(T &x, T y) {
    if(y > x)
        x = y;
}

#define dbg(x) cerr << #x " = " << (x) << endl

ll qpow(ll x, ll n, ll mod = MOD) {
    if(n < 0)
        return 0;
    ll res = 1;
    while(n) {
        if(n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll sq(ll x) {
    return x * x;
}

double sq(double x) {
    return x * x;
}

ll read() {
    ll res = 0;
    char c = getchar();
    while(!isdigit(c))
        c = getchar();
    while(isdigit(c)) {
        res = res * 10 + (c - '0');
        c = getchar();
    }
    return res;
}

int n, sum;
vi x[100005], X;

namespace Solver {

    void InitOnce() {
#ifdef LOCAL
        freopen("A.txt", "r", stdin);
#endif // LOCAL
        int t;
        scanf("%d", &t);
    }

    void Read() {
        int res = scanf("%d", &n);
        if(res == -1)
            exit(0);
        sum = 0;
        X.clear();
        for(int i = 1; i <= n; ++i) {
            x[i].clear();
            int k;
            scanf("%d", &k);
            while(k--) {
                int a;
                scanf("%d", &a);
                x[i].eb(a);
                X.eb(a);
                ++sum;
            }
        }
        uni(X);
        for(int i = 1; i <= n; ++i) {
            int k = x[i].size();
            for(int j = 0; j < k; ++j)
                x[i][j] = lower_bound(all(X), x[i][j]) - X.begin() + 1;
            srt(x[i]);
//            for(int j : x[i])
//                printf("%d ", j);
//            printf("\n");
        }
    }

    bool vis[200005];
    vector<int> Big, Small;
    vector<pii> p[200005];

    void Solve() {
        Big.clear();
        Small.clear();
        int sum2 = X.size();
        for(int i = 1; i <= sum2; ++i) {
            vis[i] = 0;
            p[i].clear();
        }
        int D = pow(1.0 * sum, 0.25);
        for(int i = 1; i <= n; ++i) {
            int k = x[i].size();
            if(k >= D)
                Big.eb(i);
            else
                Small.eb(i);
        }
        for(const int &i : Big) {
            for(const int &j : x[i])
                vis[j] = 1;
            for(const int &i2 : Small) {
                int cnt = 0;
                for(const int &j : x[i2])
                    cnt += vis[j];
                if(cnt >= 2) {
                    printf("%d %d\n", i, i2);
                    return;
                }
            }
            for(const int &j : x[i])
                vis[j] = 0;
        }
        for(const int &i : Big) {
            for(const int &j : x[i])
                vis[j] = 1;
            for(const int &i2 : Big) {
                if(i2 >= i)
                    break;
                int cnt = 0;
                for(const int &j : x[i2])
                    cnt += vis[j];
                if(cnt >= 2) {
                    printf("%d %d\n", i, i2);
                    return;
                }
            }
            for(const int &j : x[i])
                vis[j] = 0;
        }
        for(const int &i : Small) {
            int k = x[i].size();
            for(int j = 0; j < k; ++j) {
                int u = x[i][j];
                for(int j2 = j + 1; j2 < k; ++j2) {
                    int v = x[i][j2];
                    p[u].eb(v, i);
                }
            }
        }
        for(int i = 1; i <= sum2; ++i) {
            srt(p[i]);
            int k = p[i].size();
            for(int j = 1; j < k; ++j) {
                if(p[i][j].first == p[i][j - 1].first) {
                    printf("%d %d\n", p[i][j].second, p[i][j - 1].second);
                    return;
                }
            }
        }
        puts("-1");
    }

}

int main() {
    Solver::InitOnce();
    while(true) {
        Solver::Read();
        Solver::Solve();
    }
    return 0;
}

```