#include <bits/stdc++.h>
int T, n;
int cnt[205], ans[205];
bool vis[205], used[205], visp[205];
int p[205][205];
bool check(int x) {
  if (x == 1) {
    for (int i = 1; i < n; i++) {
      for (int j = 1; j <= n; j++) visp[j] = 0;
      for (int j = 1; j <= p[i][0]; j++) visp[p[i][j]] = 1;
      int idx;
      for (int j = 1; j <= n; j++)
        if (visp[ans[j]]) {
          idx = j;
          break;
        }
      for (int j = idx; j < idx + p[i][0]; j++)
        if (!visp[ans[j]]) return 0;
    }
    return 1;
  }
  int sum = 0, pos, ip;
  for (int i = 1; i <= n; i++)
    if (!vis[i] && cnt[i] == 1) sum++, ip = i;
  if (sum != 1) return 0;
  for (int i = 1; i < n; i++) {
    if (used[i]) continue;
    bool flag = 0;
    for (int j = 1; j <= p[i][0]; j++)
      if (p[i][j] == ip) {
        flag = 1;
        break;
      }
    if (flag) {
      pos = i, ans[x] = ip, used[i] = 1;
      for (int j = 1; j <= p[i][0]; j++) cnt[p[i][j]]--;
      break;
    }
  }
  int temp = check(x - 1);
  if (temp)
    return 1;
  else {
    used[pos] = ans[x] = 0;
    for (int i = 1; i <= p[pos][0]; i++) cnt[p[pos][i]]++;
    return 0;
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) cnt[i] = ans[i] = vis[i] = used[i] = 0;
    for (int i = 1; i < n; i++) {
      scanf("%d", &p[i][0]);
      for (int j = 1; j <= p[i][0]; j++) scanf("%d", &p[i][j]), cnt[p[i][j]]++;
    }
    for (int i = 1; i <= n; i++) {
      vis[i] = 1, ans[1] = i;
      if (check(n)) break;
      vis[i] = ans[1] = 0;
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
