#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void test_case() {
  int n;
  cin >> n;
  vector<vector<vector<int>>> ranges(n);
  for (int i = 0; i < n - 1; i++) {
    int k;
    cin >> k;
    vector<int> curr;
    while (k--) {
      int x;
      cin >> x;
      --x;
      curr.push_back(x);
    }
    for (int x : curr) ranges[x].push_back(curr);
  }
  vector<int> p;
  for (int start = 0; start < n; ++start) {
    int found = 0;
    vector<int> size2;
    for (vector<int> &v : ranges[start]) {
      if ((int)v.size() == 2) {
        found++;
      }
    }
    if (found != 1) continue;
    vector<int> q(n);
    vector<int> index(n, -1);
    q[0] = start;
    index[q[0]] = 0;
    bool ok = true;
    for (int i = 1; i < n; i++) {
      bool achei = false;
      for (vector<int> &v : ranges[q[i - 1]]) {
        int notseen = 0;
        int e;
        for (int &x : v) {
          if (index[x] == -1) {
            e = x;
            notseen++;
          }
        }
        if (notseen != 1) continue;
        index[e] = i;
        int mn = n, mx = -1;
        for (int &x : v) {
          mn = min(mn, index[x]);
          mx = max(mx, index[x]);
        }
        if (mx - mn + 1 != (int)v.size()) continue;
        q[i] = e;
        achei = true;
        break;
      }
      if (!achei) {
        ok = false;
        break;
      }
    }
    if (ok) {
      p = q;
      break;
    }
  }
  for (int i : p) cout << i + 1 << " ";
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    test_case();
  }
  return 0;
}
