#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k, n, t;
  cin >> t;
  string s;
  while (t--) {
    cin >> n;
    cin >> s;
    vector<char> a;
    vector<char> b;
    a.push_back('1');
    b.push_back('1');
    long long i;
    for (i = 1; s[i] != '1' && i < n; i++) {
      if (s[i] == '2') {
        a.push_back('1');
        b.push_back('1');
      } else {
        a.push_back('0');
        b.push_back('0');
      }
    }
    if (i < n) {
      a.push_back('1');
      b.push_back('0');
      i++;
    }
    for (; i < n; i++) {
      if (s[i] == '2') {
        a.push_back('0');
        b.push_back('2');
      } else if (s[i] == '1') {
        a.push_back('0');
        b.push_back('1');
      } else {
        a.push_back('0');
        b.push_back('0');
      }
    }
    for (i = 0; i < n; i++) cout << a[i];
    cout << endl;
    for (i = 0; i < n; i++) cout << b[i];
    cout << endl;
  }
}
