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