#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001001;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < (t); ++i) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool elf = false;
    vector<int> ans1(n), ans2(n);
    for (int i = 0; i < (n); ++i) {
      if (s[i] == '2') {
        if (!elf) {
          ans1[i] = 1;
          ans2[i] = 1;
        } else {
          ans1[i] = 2;
          ans2[i] = 0;
        }
      } else if (s[i] == '1') {
        if (!elf) {
          ans1[i] = 0;
          ans2[i] = 1;
          elf = true;
        } else {
          ans1[i] = 1;
          ans2[i] = 0;
        }
      } else {
        ans1[i] = 0;
        ans2[i] = 0;
      }
    }
    for (int i = 0; i < (n); ++i) cout << ans1[i];
    cout << "\n";
    for (int i = 0; i < (n); ++i) cout << ans2[i];
    cout << "\n";
  }
  return 0;
}
