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