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