#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string x;
    cin >> n >> x;
    string s1, s2;
    for (int i = 0; i < n; i++) {
      if (x[i] == '2') {
        s1 += '1';
        s2 += '1';
      }
      if (x[i] == '0') {
        s1 += '0';
        s2 += '0';
      }
      if (x[i] == '1') {
        s1 += '1';
        s2 += '0';
        break;
      }
    }
    int i = s1.length();
    while (i < n) {
      s1 += '0';
      s2 += x[i];
      i++;
    }
    cout << s1 << "\n" << s2 << "\n";
  }
  return 0;
}
