#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  x *= f;
  return;
}
long long maxt(long long a, long long b) { return a > b ? a : b; }
long long mint(long long a, long long b) { return a < b ? a : b; }
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x < 10) {
    putchar('0' + x);
    return;
  }
  write(x / 10);
  putchar(x % 10 + '0');
  return;
}
long long t, n;
long long a[205][205], ans[205], kt[205], flag;
bool vis[205], fp, pt[205];
bool check() {
  bool cnt[205];
  for (int i = 2; i <= n; i++) {
    memset(cnt, 0, sizeof(cnt));
    for (int j = i; j >= i - a[kt[i]][0] + 1; j--) cnt[ans[j]] = 1;
    for (int j = 1; j <= a[kt[i]][0]; j++)
      if (!cnt[a[kt[i]][j]]) return 0;
  }
  return 1;
}
void dfs(long long k) {
  if (k == n) {
    if (!check()) return;
    fp = 1;
    for (int i = 1; i <= n; i++) write(ans[i]), putchar(' ');
    putchar('\n');
    return;
  }
  long long cnt[205], p[205];
  memset(cnt, 0, sizeof(cnt));
  memset(p, 0, sizeof(p));
  for (int i = 1; i < n; i++)
    if (!vis[i])
      for (int j = 1; j <= a[i][0]; j++) {
        cnt[a[i][j]]++;
        p[a[i][j]] = i;
      }
  long long fg = 0, as[3];
  as[1] = as[2] = 0;
  for (int i = 1; i <= n; i++)
    if (cnt[i] == 1 && i != flag) {
      fg++;
      as[fg] = i;
    }
  if (fg == 1) {
    ans[n - k + 1] = as[fg];
    vis[p[as[fg]]] = 1;
    kt[n - k + 1] = p[as[fg]];
    dfs(k + 1);
    kt[n - k + 1] = 0;
    vis[p[as[fg]]] = 0;
    ans[n - k + 1] = 0;
  } else {
    ans[1] = as[1];
    flag = as[1];
    ans[n - k + 1] = as[2];
    vis[p[as[2]]] = 1;
    kt[n - k + 1] = p[as[2]];
    dfs(k + 1);
    kt[n - k + 1] = 0;
    vis[p[as[2]]] = 0;
    ans[n - k + 1] = 0;
    if (fp) return;
    ans[1] = as[2];
    flag = as[2];
    ans[n - k + 1] = as[1];
    vis[p[as[1]]] = 1;
    kt[n - k + 1] = p[as[1]];
    dfs(k + 1);
    kt[n - k + 1] = 0;
    vis[p[as[1]]] = 0;
    ans[n - k + 1] = 0;
  }
  return;
}
int main() {
  read(t);
  while (t--) {
    read(n);
    memset(ans, 0, sizeof(ans));
    memset(vis, 0, sizeof(vis));
    memset(a, 0, sizeof(a));
    memset(kt, 0, sizeof(kt));
    fp = 0;
    flag = 0;
    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);
  }
  return 0;
}
