#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int xx = 0, rem, sum = 0, n, count = 0;
  string x, a = {"1"}, b = {"1"};
  cin >> n >> x;
  long long int sign = 0, i;
  for (i = 1; i < n; i++) {
    if (x[i] == '1' && sign == 0) {
      a = a + '1';
      b = b + '0';
      sign = 1;
    } else if (x[i] == '2' && sign == 0) {
      a = a + '1';
      b = b + '1';
    } else if (x[i] == '0') {
      a = a + '0';
      b = b + '0';
    } else if (sign == 1) {
      a = a + '0';
      b = b + x[i];
    }
  }
  cout << a << endl;
  cout << b << endl;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fast();
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
