#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    long long flag = 0;
    cin >> n;
    string a;
    cin >> a;
    long long q[n], w[n];
    q[0] = 1;
    w[0] = 1;
    for (long long i = 1; i < n; i++) {
      if (a[i] == '2' && flag == 0) {
        q[i] = 1;
        w[i] = 1;
      } else if (a[i] == '2' && flag == 1) {
        q[i] = 0;
        w[i] = 2;
      } else if (a[i] == '1' && flag == 0) {
        q[i] = 1;
        w[i] = 0;
        flag = 1;
      } else if (a[i] == '1' && flag == 1) {
        q[i] = 0;
        w[i] = 1;
      } else if (a[i] == '0') {
        q[i] = 0;
        w[i] = 0;
      }
    }
    for (long long i = 0; i < n; i++) {
      cout << q[i];
    }
    cout << "\n";
    for (long long i = 0; i < n; i++) {
      cout << w[i];
    }
    cout << "\n";
  }
}
