#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<char> x, a, b;
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      x.push_back(c);
    }
    a.push_back('1');
    b.push_back('1');
    bool swap = false;
    for (auto it = x.begin() + 1; it != x.end(); it++) {
      if ((*it) == '0') {
        a.push_back('0');
        b.push_back('0');
      } else if (!swap) {
        if ((*it) == '1') {
          a.push_back('1');
          b.push_back('0');
          swap = true;
        } else if ((*it) == '2') {
          a.push_back('1');
          b.push_back('1');
        }
      } else if ((*it) == '1') {
        b.push_back('1');
        a.push_back('0');
      } else if ((*it) == '2') {
        a.push_back('0');
        b.push_back('2');
      }
    }
    for (auto d : a) {
      cout << d;
    }
    cout << "\n";
    for (auto d : b) {
      cout << d;
    }
    cout << "\n";
  }
  return 0;
}
