#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int f = n;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        f = i;
        break;
      }
    }
    string a, b;
    for (int i = 0; i < min(f, n); i++) {
      if (s[i] == '2') {
        a.push_back('1');
        b.push_back('1');
      } else {
        a.push_back('0');
        b.push_back('0');
      }
    }
    if (f != n) {
      a.push_back('1');
      b.push_back('0');
    }
    for (int i = f + 1; i < n; i++) {
      a.push_back('0');
      b.push_back(s[i]);
    }
    cout << a << endl;
    cout << b << endl;
  }
}
