#include <bits/stdc++.h>
using namespace std;
void solve() {}
void readinp() {
  int t;
  cin >> t;
  for (int tc = 0; tc < t; tc++) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string a, b;
    bool first = true;
    for (int i = 0; i < n; i++) {
      if (s[i] == '2') {
        if (i == 0) {
          a += "1";
          b += "1";
        } else {
          if (first) {
            a += "1";
            b += "1";
          } else {
            a += "0";
            b += "2";
          }
        }
      } else if (s[i] == '1') {
        if (first) {
          a += "1";
          b += "0";
          first = false;
        } else {
          a += "0";
          b += "1";
        }
      } else {
        a += "0";
        b += "0";
      }
    }
    cout << a << "\n";
    cout << b << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  readinp();
  return 0;
}
