#include <bits/stdc++.h>
using namespace std;
int a[300000], b[300000];
int main() {
  ios_base::sync_with_stdio(false);
  int i, t, n, j = 0, cnt = 0, k = 1, m, p = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    for (i = 0; i < n; i++) cout << a[i] << ' ';
    for (i = 0; i < n; i++) cout << b[i] << ' ';
  }
  return 0;
}
