#include <bits/stdc++.h>
void rd(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
void lrd(long long &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
const int INF = 1e9;
const long long LINF = 1e18;
const int N = 205;
using namespace std;
int T, n, ans[N], flg;
struct segment {
  int cnt, flg;
  int a[N];
  bool b[N];
  void read() {
    rd(cnt);
    memset(b, 0, sizeof(b));
    for (int i = 1; i <= cnt; i++) rd(a[i]), b[a[i]] = 1;
  }
  void init(int x) {
    cnt = 1;
    a[1] = x;
    b[x] = 1;
  }
} p[N];
bool is[N];
void dfs(int x) {
  if (flg) return;
  if (x == n + 1) {
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
    flg = 1;
    return;
  }
  for (int i = 1; i < n; i++) {
    if (p[i].cnt > x || p[i].flg) continue;
    int tmp = 0;
    for (int j = x - p[i].cnt + 1; j < x; j++)
      if (!p[i].b[ans[j]]) tmp = 1;
    if (tmp) continue;
    tmp = 0;
    for (int j = 1; j <= p[i].cnt; j++)
      if (!is[p[i].a[j]]) {
        tmp = p[i].a[j];
        break;
      }
    if (!tmp) continue;
    p[i].flg = 1;
    is[tmp] = 1;
    ans[x] = tmp;
    dfs(x + 1);
    is[tmp] = 0;
    ans[x] = 0;
    p[i].flg = 0;
    if (flg) return;
  }
}
int main() {
  rd(T);
  while (T--) {
    rd(n);
    flg = 0;
    for (int i = 1; i < n; i++) p[i].read();
    for (int i = 1; i <= n; i++)
      is[ans[1] = i] = 1, dfs(2), is[i] = 0, ans[1] = 0;
  }
  return 0;
}
