#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 2e18;
const int N = 207;
vector<int> seg[N];
bool mark[N];
vector<int> res;
int pres[N];
int discr(const vector<int> &p, int &which) {
  int fr = (int)res.size();
  int cnt = 0;
  for (int v : p) {
    if (pres[v] == -1) {
      which = v;
      ++cnt;
    } else
      fr = min(fr, pres[v]);
  }
  return (cnt == 1 and (int) res.size() - fr == (int)p.size() - 1) ? 1 : 2;
}
void clear(bool s) {
  if (s) {
    for (int i = 0; i < N; ++i) seg[i].clear();
  }
  memset(mark, false, sizeof mark);
  memset(pres, -1, sizeof pres);
  res.clear();
}
bool solve(int n, int ini) {
  clear(false);
  res = {ini};
  pres[ini] = 0;
  while ((int)res.size() < n) {
    int who = -1, val = -1;
    for (int i = 0; i + 1 < n; ++i) {
      if (mark[i]) continue;
      int d = discr(seg[i], val);
      if (d == 1) {
        who = i;
        break;
      }
    }
    if (who == -1) return false;
    mark[who] = true;
    pres[val] = (int)res.size();
    res.push_back(val);
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t, tc = 0;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    clear(true);
    for (int i = 0; i + 1 < n; ++i) {
      int k;
      cin >> k;
      seg[i].resize(k);
      for (int j = 0; j < k; ++j) cin >> seg[i][j];
    }
    for (int i = 1; i <= n; ++i) {
      if (solve(n, i)) break;
    }
    for (int x : res) cout << x << " ";
    cout << "\n";
  }
  return 0;
}
