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

void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> s(n + 2);
    map<int, int> mp;
    int total = 0;
    for (int i = 1; i <= n; i++)
    {
        int m;
        cin >> m;
        s[i].resize(m + 2);
        s[i][0] = m;
        for (int j = 1; j <= m; j++)
            cin >> s[i][j], mp[s[i][j]]++;
        total += m;
    }
    int ind = 0;
    for (auto &[x, y] : mp)
        y = ++ind;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= s[i][0]; j++)
            s[i][j] = mp[s[i][j]];
    }
    int sq = sqrt(total / 16);
    vector<int> use(ind + 2);
    // Big - big/small
    for (int i = 1; i <= n; i++)
    {
        if (s[i][0] < sq)
            continue;
        for (int j = 1; j <= s[i][0]; j++)
            use[s[i][j]] = 1;
        for (int j = 1; j <= n; j++)
        {
            if (i == j)
                continue;
            int cnt = 0;
            for (int k = 1; k <= s[j][0]; k++)
                if (use[s[j][k]])
                    ++cnt;
            if (cnt >= 2)
            {
                cout << i << " " << j << endl;
                return;
            }
        }
        for (int j = 1; j <= s[i][0]; j++)
            use[s[i][j]] = 0;
    }
    // Small-small
    vector<tuple<int, int, int>> vec;
    for (int i = 1; i <= n; i++)
    {
        if (s[i][0] >= sq)
            continue;
        for (int j = 1; j <= s[i][0]; j++)
        {
            for (int k = j + 1; k <= s[i][0]; k++)
            {
                vec.push_back({s[i][j], s[i][k], i});
            }
        }
    }
    vector<vector<pair<int, int>>> g(ind + 2);
    for (auto [x, y, z] : vec)
    {
        if (x < y)
            g[x].push_back({y, z});
        else
            g[y].push_back({x, z});
    }
    vector<int> from(ind + 2);
    // For same first value
    for (int i = 1; i <= ind; i++)
    {
        // check if same second value in different set
        for (auto [x, y] : g[i])
        {
            if (from[x] == 0)
                from[x] = y;
            else
            {
                cout << from[x] << " " << y << endl;
                return;
            }
        }
        for (auto [x, y] : g[i])
            from[x] = 0;
    }
    cout << -1 << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--)
        solve();
}