#include <bits/stdc++.h>
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double EPS = 0.001;
const long double EPS2 = 1e-6;
const long double PI = acos(-1);
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const int inf = 1e9;
const long long kekmod = 1791791791;
const long long bestmod = 1148822869;
const long long INF = 4e18;
const int mod = 1000000009;
const int MAXN = 2e5 + 1;
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<set<int>> kekers(n - 1);
    for (int i = 0; i < n - 1; ++i) {
      int k;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        int x;
        cin >> x;
        kekers[i].insert(x);
      }
    }
    for (int elem = 1; elem <= n; ++elem) {
      auto segs = kekers;
      vector<int> perm = {elem};
      bool f = 0;
      for (int len = 1; len < n; ++len) {
        for (auto &j : segs) {
          if (j.count(perm.back())) {
            j.erase(perm.back());
            continue;
          }
        }
        int cnt = 0;
        int telem = 0;
        for (int j = 0; j < segs.size(); ++j) {
          if (segs[j].size() == 1) {
            cnt++;
            telem = *segs[j].begin();
          }
        }
        if (cnt > 1 || cnt == 0) {
          f = 1;
          break;
        }
        perm.push_back(telem);
      }
      if (f) continue;
      set<set<int>> loles;
      for (auto j : kekers) loles.insert(j);
      for (int i = 0; i < perm.size(); ++i) {
        set<int> lul = {perm[i]};
        for (int j = i + 1; j < perm.size(); ++j) {
          lul.insert(perm[j]);
          loles.erase(lul);
        }
      }
      if (loles.size() == 0) {
        for (int i = 0; i < perm.size(); ++i) cout << perm[i] << ' ';
        ;
        cout << '\n';
        break;
      }
    }
  }
}
