#include <bits/stdc++.h>
using namespace std;
int t, n, umA, umB;
string x, a, b;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> x;
    a.clear();
    b.clear();
    umA = 0;
    umB = 0;
    for (int i = 0; i < x.size(); i++) {
      if (x[i] == '2') {
        if (a > b)
          a.push_back('0'), b.push_back('2');
        else if (a < b)
          a.push_back('2'), b.push_back('0');
        else
          a.push_back('1'), b.push_back('1');
      } else if (x[i] == '1') {
        if (a > b)
          a.push_back('0'), b.push_back('1');
        else
          a.push_back('1'), b.push_back('0');
      } else
        a.push_back('0'), b.push_back('0');
    }
    cout << a << '\n';
    cout << b << '\n';
  }
  return 0;
}
