#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    string s1, s2;
    s1 = "1";
    s2 = "1";
    bool mark = false;
    for (long long int i = 1; i < s.length(); i++) {
      if (s[i] == '2') {
        if (mark) {
          s1 += '0';
          s2 += '2';
        } else {
          s1 += '1';
          s2 += '1';
        }
      } else if (s[i] == '0') {
        s1 += '0';
        s2 += '0';
      } else {
        if (mark == false) {
          s1 += '1';
          s2 += '0';
        } else {
          s1 += '0';
          s2 += '1';
        }
        mark = true;
      }
    }
    cout << s1 << "\n" << s2 << "\n";
  }
}
