#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<set<int>> v(n);
    for (int i = 0; i < n - 1; ++i) {
      int m;
      cin >> m;
      for (int j = 0; j < m; ++j) {
        int x;
        cin >> x;
        v[i].insert(x);
      }
    }
    for (int i = 1; i <= n; i++) {
      vector<int> ans;
      vector<int> setsRemoved;
      int elementToRemove = i;
      ans.push_back(i);
      vector<set<int>> temp = v;
      vector<bool> done(n + 1);
      for (int l = 0; l < n - 1; ++l) {
        int k = -1;
        for (int j = 0; j < n - 1; ++j) {
          temp[j].erase(elementToRemove);
          if (k == -1 && temp[j].size() == 1)
            k = j;
          else if (temp[j].size() == 1) {
            k = -2;
            break;
          }
        }
        if (k < 0) break;
        ans.push_back(*temp[k].begin());
        setsRemoved.push_back(k);
        done[k] = 1;
        elementToRemove = *temp[k].begin();
      }
      if (ans.size() < n - 1) continue;
      done.clear();
      done.resize(n);
      bool check = 1;
      for (int j = 1; j < n - 1; ++j) {
        set<int> st;
        for (int k = j - 1; k > j - v[setsRemoved[j]].size() + 1; k--) {
          if (v[setsRemoved[j]].find(ans[k]) == v[setsRemoved[j]].end()) {
            check = 0;
            break;
          }
        }
        if (!check) break;
      }
      if (!check) continue;
      for (int j = 0; j < n; j++) cout << ans[j] << " ";
      cout << "\n";
      break;
    }
  }
  return 0;
}
