//#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 = sqrt(1.0 * n / log(n));
        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;
}
