#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mod = 1000000007;
int n;
int ans[N], cnt[N];
vector<int> a[N], b[N];
set<int> s[N];
set<int> flag;
bool gao(int st) {
  flag.clear();
  int now = st;
  for (int i = 0; i < n - 1; i++) {
    s[i].clear();
    for (int j = 0; j < a[i].size(); j++) {
      s[i].insert(a[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    ans[i] = now;
    int nxt = -1;
    int del = 0;
    int expected = flag.size();
    for (int j = 0; j < b[now].size(); j++) {
      int idx = b[now][j];
      s[idx].erase(now);
      if (flag.find(idx) != flag.end()) {
        del++;
        if (s[idx].size() == 0) {
          flag.erase(idx);
        }
      } else {
        flag.insert(idx);
      }
      if (s[idx].size() == 1) {
        if (nxt != -1) return false;
        nxt = *s[idx].begin();
      }
    }
    if (del != expected) return false;
    now = nxt;
  }
  return true;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      b[i].clear();
    }
    for (int i = 0; i < n - 1; i++) {
      a[i].clear();
      cin >> cnt[i];
      for (int j = 0; j < cnt[i]; j++) {
        int m;
        cin >> m;
        a[i].push_back(m);
        b[m].push_back(i);
      }
    }
    for (int st = 1; st <= n; st++) {
      if (gao(st)) {
        for (int i = 0; i < n - 1; i++) {
          cout << ans[i] << " ";
        }
        cout << ans[n - 1] << endl;
        break;
      }
    }
  }
  return 0;
}
