#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int MAX_N = 205;
const int MOD = 1e9 + 7, P = 239;
int n;
unordered_set<int> a[MAX_N], b[MAX_N];
int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
int sub(int x, int y) { return x - y < 0 ? x - y + MOD : x - y; }
int mul(int x, int y) { return 1ll * x * y % MOD; }
int deg(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = mul(res, x);
    y >>= 1, x = mul(x, x);
  }
  return res;
}
int ans[MAX_N];
bool is_going[MAX_N];
void solve() {
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    int k;
    cin >> k;
    a[i].clear();
    while (k--) {
      int x;
      cin >> x;
      a[i].insert(x);
    }
  }
  for (ans[1] = 1; ans[1] <= n; ++ans[1]) {
    for (int i = 1; i <= n - 1; ++i) {
      b[i] = a[i];
      is_going[i] = false;
      if (b[i].count(ans[1])) {
        b[i].erase(ans[1]);
        is_going[i] = true;
      }
    }
    bool ok = true;
    for (int i = 2; ok && i <= n; ++i) {
      int go = 0;
      bool flag = true;
      for (int j = 1; j <= n - 1; ++j) {
        if ((int)b[j].size() == 1) {
          if (go) flag = false;
          go = j;
        }
      }
      if (!go || !flag) {
        ok = false;
        break;
      }
      ans[i] = *b[go].begin();
      for (int j = 1; j <= n - 1; ++j) {
        if (b[j].count(ans[i])) {
          b[j].erase(ans[i]);
          is_going[j] = true;
          if (b[j].empty()) is_going[j] = false;
        } else if (is_going[j]) {
          ok = false;
          break;
        }
      }
    }
    if (ok) {
      for (int i = 1; i <= n; ++i) {
        cout << ans[i] << " ";
      }
      cout << "\n";
      return;
    }
  }
  cout << "NO\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
