#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e5 + 123);
const int INF = (int)(1e9 + 7);
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, ok = false, w = false;
    string s, a, b;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '0') a += '0', b += '0';
      if (s[i] == '1') {
        if (w)
          a += '0', b += '1';
        else
          a += '1', b += '0', w = true;
      }
      if (s[i] == '2') {
        if (w)
          a += '0', b += '2';
        else
          a += '1', b += '1';
      }
    }
    cout << a << endl << b << endl;
  }
}
