#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int T, n, len[N], a[N][N], pos[N], ans[N];
bool check() {
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j < n; j++) {
      int p = len[j], tmp = -1;
      for (int k = 1; k <= len[j]; k++) {
        if (!pos[a[j][k]])
          tmp = a[j][k];
        else if (pos[a[j][k]] >= i - len[j] + 1)
          p--;
      }
      if (p == 1 && tmp != -1) {
        ans[i] = tmp;
        pos[tmp] = i;
        break;
      }
    }
    if (ans[i] == 0) return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
      scanf("%d", &len[i]);
      for (int j = 1; j <= len[i]; j++) scanf("%d", &a[i][j]);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) pos[j] = ans[j] = 0;
      ans[1] = i;
      pos[i] = 1;
      if (check()) break;
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
  }
  return 0;
}
