#include <bits/stdc++.h>
using namespace std;
int main() {
  bool is[60];
  int n, t;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n], b[n], ans[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    memset(is, 0, sizeof(is));
    int l = 0;
    for (int i = 0; i < n; i++) {
      if (is[a[i]] == 0) {
        ans[l++] = a[i];
        is[a[i]] = true;
      }
    }
    for (int i = 0; i < n; i++) {
      if (is[b[i]] == 0) {
        ans[l++] = b[i];
        is[b[i]] = true;
      }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
