#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
using namespace std;
clock_t start_time, end_time;
void open() {
  ((void)0);
  ((void)0);
  ((void)0);
  ((void)0);
}
void close() {
  ((void)0);
  ((void)0);
}
const int MAX = 2e2 + 1;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1);
const long double ERR = 1e-10;
const int move_r[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int move_c[] = {0, -1, 0, 1, -1, 1, -1, 1};
int t, n, len, a, sv[MAX], nv[MAX];
vector<int> seg[MAX], idx[MAX], ans;
int find(int cur) {
  for (int li : idx[cur])
    if (!sv[li]) return li;
  return -1;
}
bool solve(int cur, vector<int> tcnt, int p) {
  if (!p) {
    ans.push_back(cur);
    int li = find(cur);
    for (int val : seg[li])
      if (val != cur) ans.push_back(val);
    return true;
  }
  ans.push_back(cur);
  int li = find(cur);
  sv[li] = 1;
  vector<int> tmp;
  for (int val : seg[li]) {
    tcnt[val]--;
    nv[val]++;
    if (tcnt[val] == 1) tmp.push_back(val);
  }
  int target = -1;
  if (tmp.size() == 2)
    target = nv[tmp[0]] > nv[tmp[1]] ? tmp[0] : tmp[1];
  else if (tmp.size() == 1)
    target = tmp[0];
  if (target > 0 && solve(target, tcnt, p - 1)) return true;
  sv[li] = 0;
  ans.pop_back();
  return false;
}
int main(int argc, char *argv[]) {
  open();
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      seg[i].clear();
      idx[i].clear();
      sv[i] = nv[i] = 0;
    }
    ans.clear();
    vector<int> cnt(n + 1, 0);
    for (int i = 1; i < n; ++i) {
      scanf("%d", &len);
      while (len--) {
        scanf("%d", &a);
        cnt[a]++;
        seg[i].push_back(a);
        idx[a].push_back(i);
      }
    }
    for (int i = 1; i <= n; ++i)
      if (cnt[i] == 1 && solve(i, cnt, n - 2)) break;
    for (int i = (int)ans.size() - 1; i >= 0; --i) printf("%d ", ans[i]);
    puts("");
  }
  close();
  return 0;
}
