#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<pair<set<long long>, long long>> arr(n - 1);
    long long s, a;
    for (long long i = 0; i < n - 1; i++) {
      cin >> s;
      for (long long j = 0; j < s; j++) {
        cin >> a;
        arr[i].first.insert(a);
      }
      arr[i].second = 0;
    }
    for (long long i = 1; i < n + 1; i++) {
      long long poss = 1;
      vector<long long> ans(n), vis(n - 1, 1);
      auto tmp = arr;
      ans[0] = i;
      for (long long k = 0; k < tmp.size(); k++) {
        if (tmp[k].first.find(ans[0]) != tmp[k].first.end()) {
          tmp[k].first.erase(ans[0]);
          tmp[k].second = 1;
        }
      }
      for (long long j = 1; j < n; j++) {
        long long p = 0;
        for (long long k = 0; k < tmp.size(); k++) {
          if (!vis[k]) continue;
          if (tmp[k].first.size() == 1) {
            p = 1;
            ans[j] = *tmp[k].first.begin();
            tmp[k].first.erase(ans[j]);
            vis[k] = 0;
            break;
          }
        }
        if (!p) {
          poss = 0;
          break;
        }
        for (long long k = 0; k < tmp.size(); k++) {
          if (!vis[k])
            continue;
          else if (tmp[k].first.find(ans[j]) != tmp[k].first.end()) {
            tmp[k].first.erase(ans[j]);
            tmp[k].second = 1;
          } else if (tmp[k].second == 1) {
            p = 0;
            break;
          }
        }
        if (p == 0) {
          poss = 0;
          break;
        }
      }
      if (poss) {
        for (auto i : ans) cout << i << " ";
        ;
        cout << "\n";
        break;
      }
    }
  }
}
