#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using matr = vector<vector<ll>>;
using dbl = long double;
using ui = unsigned int;
mt19937 rnd;
ll random(ll limit) {
  uniform_int_distribution<ll> uniform_dist(0, limit);
  return uniform_dist(rnd);
}
int n;
bool chek(vector<set<int>> x, vector<int> p) {
  set<set<int>> s;
  for (auto v : x) s.insert(v);
  for (int i = 1; i <= p.size() - 1; i++) {
    set<int> ss;
    ss.insert(p[i]);
    int j = i - 1;
    while (j >= 0 && s.count(ss) == 0) {
      ss.insert(p[j]);
      j--;
    }
    if (s.count(ss) == 0) return false;
  }
  return true;
}
pair<vector<int>, bool> solve(vector<set<int>> x, int a) {
  int n = x.size() + 1;
  set<int> s;
  for (int i = 1; i <= n; i++)
    if (i != a) s.insert(i);
  for (int i = 0; i < x.size(); i++) x[i].erase(a);
  vector<int> q = {a};
  for (int j = 1; j < n; j++) {
    int b = -1;
    for (int i = 0; i < x.size(); i++) {
      if (x[i].size() == 1) {
        b = *(x[i].begin());
      }
    }
    if (b == -1) return {{}, false};
    q.push_back(b);
    for (int i = 0; i < x.size(); i++) x[i].erase(q[j]);
  }
  return {q, true};
}
int main() {
  rnd = mt19937(956231);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<set<int>> x;
    for (int i = 0; i < n - 1; i++) {
      set<int> q;
      int a;
      cin >> a;
      while (a--) {
        int b;
        cin >> b;
        q.insert(b);
      }
      x.push_back(q);
    }
    for (int i = 1; i <= n; i++) {
      auto p = solve(x, i);
      if (p.second && chek(x, p.first)) {
        for (auto v : p.first) cout << v << ' ';
        break;
      }
    }
    cout << '\n';
  }
}
