#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<set<long long>> lol(n - 1);
    long long cnt = 0;
    long long x;
    for (long long i = 0; i < n - 1; i++) {
      cin >> cnt;
      for (long long j = 0; j < cnt; j++) {
        cin >> x;
        lol[i].insert(x);
      }
    }
    for (long long i = 1; i <= n; i++) {
      bool ok = 1;
      vector<set<long long>> st(lol.begin(), lol.end());
      long long need = i;
      for (auto &z : st) {
        z.erase(need);
      }
      vector<long long> ans;
      ans.emplace_back(i);
      for (long long j = 1; j < n; j++) {
        long long cur = -1;
        long long how = 0;
        for (auto &z : st) {
          if (z.size() == 1) {
            cur = (*z.begin());
            how++;
          }
        }
        if (how != 1) {
          ok = 0;
          break;
        }
        ans.emplace_back(cur);
        for (auto &z : st) z.erase(cur);
      }
      if (!ok) continue;
      set<set<long long>> kavo(lol.begin(), lol.end());
      for (long long k = 2; k < n; k++) {
        set<long long> now;
        now.insert(ans[k]);
        bool is = 0;
        for (long long j = k - 1; j >= 0; j--) {
          now.insert(ans[j]);
          if (kavo.count(now)) {
            kavo.erase(now);
            is = 1;
            break;
          }
        }
        if (!is) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        for (auto z : ans) {
          cout << z << " ";
        }
        cout << '\n';
        break;
      }
    }
  }
  return 0;
}
