#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 200010;
int tc, cs = 1;
int n, ptr, sz[N];
vector<int> v[N], big, small;
map<int, int> mp;

bool checkbig() {
  vector<bool> tmp(ptr, 0);
  for (int id: big) {
    for (auto p: v[id]) tmp[p] = 1;
    for (int i = 1; i <= n; ++i) {
      if (i == id) continue;
      int cnt = 0;
      for (auto p: v[i]) {
        if (tmp[p]) ++cnt;
      }
      if (cnt >= 2) {
        cout << id << " " << i << '\n';
        return true;
      }
    }
    for (auto p: v[id]) tmp[p] = 0;
  }
  return false; 
}

void test_cases() {
  big.clear();
  small.clear();
  mp.clear();
  cin >> n;
  ptr = 1;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> sz[i];
    v[i].clear();
    for (int j = 1; j <= sz[i]; ++j) {
      int x;
      cin >> x;
      if (mp.find(x) == mp.end()) {
        mp[x] = ptr;
        x = ptr;
        ptr++;
      } else x = mp[x];
      v[i].push_back(x);
    }
    sum += sz[i];
  }
  int sq = sqrt(sum)+1;
  for (int i = 1; i <= n; ++i) {
    if (sz[i] >= sq) big.push_back(i);
    else small.push_back(i);
  }
  if (checkbig()) return;
  vector<int> sets[ptr], lst(ptr, 0);
  for (auto id: small) {
    for (int i: v[id]) sets[i].push_back(id);
  }
  for (int cur = 1; cur < ptr; ++cur) {
    for (int id: sets[cur]) {
      for (int p: v[id]) {
        if (p != cur && lst[p]) {
          cout << lst[p] << " " << id << '\n';
          return;
        }
        if (p != cur) lst[p] = id;
      }
    }
    for (int id: sets[cur]) {
      for (int p: v[id]) lst[p] = 0;
    }
  }
  cout << "-1" << '\n';
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> tc;
  while (tc--) {
    test_cases();
  }
}