#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c<'0' | c> '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
const int N = 300005;
const int MOD = 1e9 + 7;
int main() {
  int t = ({
    int a;
    read(a);
    a;
  });
  while (t--) {
    int n = ({
      int a;
      read(a);
      a;
    });
    string s;
    cin >> s;
    string a = "", b = "";
    bool f = false;
    for (int i = 0; s[i]; ++i) {
      if (s[i] == '0') {
        a += "0", b += "0";
      } else if (s[i] == '1') {
        if (f) {
          a += "0", b += "1";
        } else {
          a += "1", b += "0";
          f = true;
        }
      } else {
        if (f) {
          a += "0", b += "2";
        } else {
          a += "1", b += "1";
        }
      }
    }
    cout << a << '\n' << b << '\n';
  }
}
