#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T>
bool uax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool uin(T& a, const T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
  out << p.first << ' ' << p.second;
  return out;
}
const int N = 200 + 7;
int n;
vector<int> g[N];
vector<int> p[N];
int sz[N];
int ans[N];
vector<int> wr;
int s[N];
bool used[N];
int last_ind = 0;
int arr[N];
void del(int x) {
  used[x] = true;
  for (int i = 0; i < p[x].size(); i++) {
    s[p[x][i]]--;
    if (s[p[x][i]] == 1) {
      arr[last_ind++] = p[x][i];
    }
  }
}
bool solve(int x) {
  last_ind = 0;
  for (int i = 0; i <= n; i++) {
    s[i] = sz[i];
    used[i] = false;
  }
  ans[0] = x;
  del(x);
  for (int i = 1; i < n; i++) {
    if (last_ind != 1) {
      return false;
    }
    int ind = arr[0];
    int cur = 0;
    for (int j = 0; j < g[ind].size(); j++) {
      if (!used[g[ind][j]]) cur = g[ind][j];
    }
    ans[i] = cur;
    wr.clear();
    for (int j = 0; j < sz[ind]; j++) {
      wr.push_back(ans[i - j]);
    }
    sort(wr.begin(), wr.end());
    for (int j = 0; j < g[ind].size(); j++) {
      if (g[ind][j] != wr[j]) return false;
    }
    last_ind = 0;
    del(cur);
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    fill(p, p + n + 1, vector<int>());
    cin >> n;
    int k;
    for (int i = 0; i < n - 1; i++) {
      cin >> k;
      g[i].resize(k);
      sz[i] = k;
      for (int j = 0; j < k; j++) {
        cin >> g[i][j];
        p[g[i][j]].push_back(i);
      }
    }
    for (int i = 1; i <= n; i++) {
      if (solve(i)) {
        break;
      }
    }
  }
}
