#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const long long LINF = LLONG_MAX;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
void solve() {
  int n;
  string num, a = "", b = "";
  cin >> n >> num;
  for (int i = 0; i < n; ++i) {
    if (num[i] == '2') {
      a += "1";
      b += "1";
    } else if (num[i] == '0') {
      a += "0";
      b += "0";
    } else {
      a += "1";
      b += "0";
      for (int j = i + 1; j < n; ++j) {
        a += "0";
        b += num[j];
      }
      break;
    }
  }
  cout << a << '\n' << b << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
