#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string input;
    cin >> input;
    string ans1 = "1";
    string ans2 = "1";
    bool is1 = false;
    for (int i = 1; i < n; i++) {
      if (input[i] == '0') {
        ans1 += "0";
        ans2 += "0";
      }
      if (is1 == false) {
        if (input[i] == '2') {
          ans1 += "1";
          ans2 += "1";
        }
        if (input[i] == '1') {
          ans1 += "1";
          ans2 += "0";
          is1 = true;
        }
      } else {
        if (input[i] == '2') {
          ans1 += "0";
          ans2 += "2";
        }
        if (input[i] == '1') {
          ans1 += "0";
          ans2 += "1";
        }
      }
    }
    cout << ans1 << endl;
    cout << ans2 << endl;
  }
  return 0;
}
