#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    string s;
    cin >> s;
    string res1 = "1";
    string res2 = "1";
    int flag = 0;
    for (int i = 1; i < s.length(); i++) {
      if (s[i] == '0') {
        res1 += "0";
        res2 += "0";
      } else {
        if (s[i] == '1' && flag == 0) {
          res1 += "1";
          res2 += "0";
          flag = 1;
        } else if (s[i] == '1' && flag == 1) {
          res1 += "0";
          res2 += "1";
        } else if (s[i] == '2' && flag == 0) {
          res1 += "1";
          res2 += "1";
        } else if (s[i] == '2' && flag == 1) {
          res1 += "0";
          res2 += "2";
        }
      }
    }
    cout << res1 << endl << res2 << endl;
  }
  return 0;
}
