#include <bits/stdc++.h>
using namespace std;
const int N = 205;
vector<int> g[N];
int vis[N];
int n;
int ans[N];
bool check(int f) {
  for (int i = 1; i <= n; i++) vis[i] = -1;
  int indx = 0;
  vis[f] = 1;
  ans[++indx] = f;
  for (int k = 1; k < n; k++) {
    bool found = 0;
    for (int i = 1; i < n; i++) {
      int mx = 0, mn = n, cnt = 0;
      int sv = -1;
      for (auto &x : g[i]) {
        cnt += vis[x] == -1;
        if (cnt > 1) break;
        if (vis[x] != -1)
          mx = max(mx, vis[x]), mn = min(mn, vis[x]);
        else
          sv = x;
      }
      if (cnt == 1 && mx == indx && mn == indx - g[i].size() + 2) {
        found = 1;
        ans[++indx] = sv;
        vis[sv] = indx;
        break;
      }
    }
    if (!found) return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i < n; i++) {
      int k;
      cin >> k;
      g[i].resize(k);
      for (auto &x : g[i]) cin >> x;
    }
    for (int i = 1; i <= n; i++)
      if (check(i)) break;
    for (int i = 1; i <= n; i++) cout << ans[i] << " \n"[i == n];
  }
  return 0;
}
