#include <bits/stdc++.h>
using namespace std;
const long long Max = 205;
int main() {
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<set<int> > seg;
    for (int i = 1; i < n; i++) {
      int len;
      cin >> len;
      set<int> temp;
      for (int j = 0; j < len; j++) {
        int x;
        cin >> x;
        temp.insert(x);
      }
      seg.push_back(temp);
    }
    for (int st = 1; st <= n; st++) {
      vector<int> ans;
      bool flag = 0;
      vector<set<int> > cur = seg;
      for (auto &it : cur) {
        if (it.count(st)) it.erase(st);
      }
      ans.push_back(st);
      for (int i = 1; i < n; i++) {
        int temp = 0;
        for (auto &it : cur) {
          if (it.size() == 1) {
            temp = *it.begin();
          }
        }
        if (!temp) {
          flag = 1;
          break;
        }
        ans.push_back(temp);
        for (auto &it : cur) {
          if (it.count(temp)) it.erase(temp);
        }
      }
      if (flag) continue;
      set<set<int> > s;
      for (auto &it : seg) s.insert(it);
      for (int R = 1; R < n; R++) {
        set<int> temp;
        flag = 0;
        for (int L = R; L >= 0; L--) {
          temp.insert(ans[L]);
          if (s.count(temp)) {
            s.erase(temp);
            flag = 1;
            break;
          }
        }
        if (!flag) break;
      }
      if (!flag) continue;
      for (auto i : ans) cout << i << " ";
      break;
    }
    cout << '\n';
  }
}
