#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int aa[200][200], kk[200], qu[200], dd[200], hh[200], ii[200], n;
int solve2(int i_, int j_, int cnt) {
  static int dd_[200], hh_[200], ii_[200];
  static char used[200];
  int g, h, i;
  memcpy(dd_, dd, n * sizeof *dd);
  memcpy(hh_, hh, n * sizeof *hh);
  memcpy(ii_, ii, n * sizeof *ii);
  i = i_;
  while (cnt < n - 1) {
    qu[ii_[i] = n - 1 - cnt++] = i;
    h = hh_[i];
    i = -1;
    for (g = 0; g < kk[h]; g++) {
      int j = aa[h][g];
      hh_[j] ^= h, dd_[j]--;
      if (j != i && j != j_ && dd_[j] == 1) {
        if (i == -1)
          i = j;
        else
          return 0;
      }
    }
    if (cnt < n - 1 && i == -1) return 0;
  }
  qu[ii_[j_] = n - 1 - cnt++] = j_;
  for (i = 0; i < n; i++)
    if (ii_[i] == -1) return 0;
  memset(used, 0, n * sizeof *used);
  for (h = 0; h < n - 1; h++) {
    int l = n, r = -1;
    for (g = 0; g < kk[h]; g++) {
      int j = aa[h][g];
      l = min(l, ii_[j]), r = max(r, ii_[j]);
    }
    if (r - l + 1 != kk[h] || r == 0) return 0;
    if (used[r]) return 0;
    used[r] = 1;
  }
  return 1;
}
void solve1() {
  int cnt, g, h;
  memset(ii, -1, n * sizeof *ii);
  cnt = 0;
  while (1) {
    int i, i_;
    i_ = -1;
    for (i = 0; i < n; i++)
      if (dd[i] == 1) {
        if (i_ == -1)
          i_ = i;
        else {
          if (!solve2(i_, i, cnt)) solve2(i, i_, cnt);
          return;
        }
      }
    i = i_;
    qu[ii[i] = n - 1 - cnt++] = i;
    h = hh[i];
    for (g = 0; g < kk[h]; g++) {
      int j = aa[h][g];
      hh[j] ^= h, dd[j]--;
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int g, h, i;
    scanf("%d", &n);
    memset(dd, 0, n * sizeof *dd);
    memset(hh, 0, n * sizeof *hh);
    for (h = 0; h < n - 1; h++) {
      int k;
      scanf("%d", &k), kk[h] = k;
      for (g = 0; g < k; g++) {
        scanf("%d", &i), i--;
        aa[h][g] = i;
        dd[i]++, hh[i] ^= h;
      }
    }
    solve1();
    for (i = 0; i < n; i++) printf("%d ", qu[i] + 1);
    printf("\n");
  }
  return 0;
}
