#include <bits/stdc++.h>
using namespace std;
bool solve() {
  int n;
  cin >> n;
  string s, ans1, ans2;
  ans1 += '1';
  ans2 += '1';
  cin >> s;
  int big = 0, was = 0;
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == '2') {
      if (was) {
        ans1 += '0';
        ans2 += '2';
      } else {
        ans1 += '1';
        ans2 += '1';
      }
    } else if (s[i] == '1') {
      if (was) {
        ans1 += '0';
        ans2 += '1';
      } else {
        ans1 += '1';
        ans2 += '0';
        was = 1;
      }
    } else if (s[i] == '0') {
      ans1 += '0';
      ans2 += '0';
    }
  }
  cout << ans1 << "\n" << ans2 << "\n";
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
}
