#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
  return;
}
long long t, n, a[205][205], p[205], kt[205], flag;
bool check() {
  bool vis[205];
  for (int i = 2; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    for (int j = i; j >= i - a[kt[i]][0] + 1; j--) vis[p[j]] = 1;
    for (int j = 1; j <= a[kt[i]][0]; j++)
      if (!vis[a[kt[i]][j]]) return 0;
  }
  return 1;
}
bool fp, vs[205];
void dfs(long long k) {
  if (k == n) {
    if (!check()) return;
    for (int i = 1; i <= n; i++) printf("%lld ", p[i]);
    putchar('\n');
    fp = 1;
    return;
  }
  long long cnt[205], ts[205], as[3] = {0, 0, 0}, ps = 0;
  memset(cnt, 0, sizeof(cnt));
  memset(ts, 0, sizeof(ts));
  for (int i = 1; i < n; i++)
    if (!vs[i])
      for (int j = 1; j <= a[i][0]; j++) cnt[a[i][j]]++, ts[a[i][j]] = i;
  for (int i = 1; i <= n; i++)
    if (cnt[i] == 1 && i != flag) as[++ps] = i;
  if (ps == 1) {
    p[n - k + 1] = as[ps];
    vs[ts[as[ps]]] = 1;
    kt[n - k + 1] = ts[as[ps]];
    dfs(k + 1);
    p[n - k + 1] = 0;
    vs[ts[as[ps]]] = 0;
    kt[n - k + 1] = 0;
  } else {
    p[1] = as[2];
    p[n - k + 1] = as[1];
    vs[ts[as[1]]] = 1;
    kt[n - k + 1] = ts[as[1]];
    flag = as[2];
    dfs(k + 1);
    vs[ts[as[1]]] = 0;
    p[1] = 0;
    p[n - k + 1] = 0;
    kt[n - k + 1] = 0;
    flag = 0;
    if (fp) return;
    p[1] = as[1];
    p[n - k + 1] = as[2];
    vs[ts[as[2]]] = 1;
    kt[n - k + 1] = ts[as[2]];
    flag = as[1];
    dfs(k + 1);
    p[1] = 0;
    p[n - k + 1] = 0;
    vs[ts[as[2]]] = 0;
    kt[n - k + 1] = 0;
    flag = 0;
    if (fp) return;
  }
}
int main() {
  read(t);
  while (t--) {
    memset(a, 0, sizeof(a));
    memset(p, 0, sizeof(p));
    memset(kt, 0, sizeof(kt));
    memset(vs, 0, sizeof(vs));
    flag = 0;
    fp = 0;
    read(n);
    for (int i = 1; i < n; i++) {
      read(a[i][0]);
      for (int j = 1; j <= a[i][0]; j++) read(a[i][j]);
    }
    dfs(1);
  }
}
