#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
int n, ans[220], pos[220];
vector<int> v[220];
bool check() {
  for (auto i = (2); i <= (n); ++i) {
    for (auto j = (2); j <= (n); ++j) {
      int sz = v[j][0], num = 0, x = 0;
      for (auto k = (1); k <= (sz); ++k) {
        int u = v[j][k];
        if (!pos[u])
          x = u;
        else if (pos[u] > i - sz)
          num++;
      }
      if (num == sz - 1 && x) {
        ans[i] = x;
        pos[x] = i;
        break;
      }
    }
    if (!ans[i]) return 0;
  }
  return 1;
}
void solve() {
  scanf("%d", &n);
  for (auto i = (1); i <= (n); ++i) v[i].clear();
  for (auto i = (2); i <= (n); ++i) {
    int k;
    scanf("%d", &k);
    v[i].push_back(k);
    for (auto j = (1); j <= (k); ++j) {
      int x;
      scanf("%d", &x);
      v[i].push_back(x);
    }
  }
  for (auto i = (1); i <= (n); ++i) {
    memset(ans, 0, sizeof(ans));
    memset(pos, 0, sizeof(pos));
    ans[1] = i;
    pos[i] = 1;
    if (check()) {
      for (auto j = (1); j <= (n); ++j) printf(j == n ? "%d\n" : "%d ", ans[j]);
      return;
    }
  }
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
}
