#include <bits/stdc++.h>
using namespace std;
template <class IT>
inline void cmax(IT &a, IT b) {
  if (a < b) a = b;
}
template <class IT>
inline void cmin(IT &a, IT b) {
  if (b < a) a = b;
}
const int N = 205;
vector<int> A[N];
int F[N][N], S[N], P[N], C[N];
inline void red(int n, int a) {
  int d;
  for (d = (1); d <= (n); ++d)
    if (F[d][a]) {
      F[d][a] = 0;
      --S[d];
    }
}
inline bool chk(int n, int d, int c) {
  int i;
  for (i = (1); i <= (n); ++i) C[i] = 0;
  i = A[d].size();
  while (i--) C[A[d][i]] = 1;
  for (i = (c - A[d].size() + 1); i <= (c); ++i)
    if (!C[P[i]]) return true;
  return false;
}
inline bool sol(int n, int f) {
  int a, d, i, j;
  for (d = (2); d <= (n); ++d) {
    S[d] = i = A[d].size();
    for (a = (1); a <= (n); ++a) F[d][a] = 0;
    while (i--) F[d][A[d][i]] = 1;
  }
  red(n, P[1] = f);
  for (i = (2); i <= (n); ++i) {
    d = 0;
    for (j = (2); j <= (n); ++j)
      if (S[j] == 1) {
        if (d)
          return false;
        else
          d = j;
      }
    if (!d) return false;
    for (a = (1); a <= (n); ++a)
      if (F[d][a]) break;
    red(n, P[i] = a);
    if (chk(n, d, i)) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int n, i, k, a;
    cin >> n;
    for (i = (2); i <= (n); ++i) {
      cin >> k;
      A[i].clear();
      while (k--) {
        cin >> a;
        A[i].push_back(a);
      }
    }
    for (i = (1); i <= (n); ++i)
      if (sol(n, i)) break;
    for (i = (1); i <= (n); ++i) cout << P[i] << " ";
    cout << "\n";
  }
  return 0;
}
