#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tests;
  cin >> tests;
  while (tests--) {
    long long n;
    cin >> n;
    string bigger;
    string smaller;
    bigger = smaller = "";
    bool split = false;
    for (long long i = 1; i <= n; i += 1) {
      char a;
      cin >> a;
      if (!split && a == '2') {
        bigger += '1';
        smaller += '1';
      } else if (!split && a == '1') {
        bigger += '1';
        smaller += '0';
        split = true;
      } else {
        bigger += '0';
        smaller += a;
      }
    }
    cout << bigger << "\n" << smaller << "\n";
  }
}
