#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 110;
long long a[N], b[N], c[N];
signed main() {
  long long n, m, x, y, z = 0, ans = 0, t;
  cin >> t;
  while (t--) {
    cin >> n;
    x = n + 1;
    for (long long i = 1; i <= n; i++) {
      scanf("%1d", &a[i]);
    }
    for (long long i = 1; i <= n; i++) {
      if (a[i] == 1) {
        x = i;
        break;
      }
    }
    for (long long i = 1; i < x && i <= n; i++) {
      b[i] = c[i] = a[i] / 2;
    }
    b[x] = 1;
    c[x] = 0;
    for (long long i = x + 1; i <= n; i++) {
      b[i] = 0;
      c[i] = a[i];
    }
    for (long long i = 1; i <= n; i++) {
      cout << b[i];
    }
    cout << endl;
    for (long long i = 1; i <= n; i++) {
      cout << c[i];
    }
    cout << endl;
  }
  return 0;
}
