#include <bits/stdc++.h>
using namespace std;
long long t, n;
string s;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
int main() {
  t = read();
  while (t--) {
    string s1, s2;
    int i;
    n = read();
    cin >> s;
    for (i = 0; i < n; i++) {
      if (s[i] == '2') {
        s1 += '1';
        s2 += '1';
      } else if (s[i] == '0') {
        s1 += '0';
        s2 += '0';
      } else
        break;
    }
    if (i <= n - 1) {
      s1 += '1';
      s2 += '0';
      for (int j = i + 1; j < n; j++) {
        s1 += '0';
        s2 += s[j];
      }
    }
    cout << s1 << endl << s2 << endl;
  }
  return 0;
}
