#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    string n;
    int x;
    cin >> x >> n;
    string a = "1", b = "1";
    int c = 0;
    for (long long i = 1; i < x; i++) {
      if (n[i] == '0') {
        a += "0";
        b += "0";
      } else if (n[i] == '1') {
        if (c == 0) {
          a += "1";
          b += "0";
          c = 1;
        } else {
          a += "0";
          b += "1";
          c = 1;
        }
      } else if (c == 0) {
        a += "1";
        b += "1";
      } else {
        a += "0";
        b += "2";
      }
    }
    cout << a << endl;
    cout << b << endl;
  }
  return 0;
}
