#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, o = 0;
  cin >> t;
  while (t--) {
    long long int n, k, x = 0, y = 1;
    cin >> n;
    string a, b = "", c = "";
    cin >> a;
    for (long long int i = 0; i < n; i++) {
      if (a[i] == '0') {
        b += '0', c += '0';
      } else if (a[i] == '2') {
        if (y == 1) {
          b += '1', c += '1';
        } else {
          b += '0', c += '2';
        }
      } else {
        if (y == 1) {
          y = 0;
          b += '1', c += '0';
        } else {
          b += '0', c += '1';
        }
      }
    }
    cout << b << endl;
    cout << c << endl;
  }
}
