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