#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    int N;
    string S;
    cin >> N >> S;
    int Who = -1;
    string Ans1 = "", Ans2 = "";
    for (int i = 0; i < N; i++) {
      if (S[i] == '2' && !(~Who)) {
        Ans1.push_back('1');
        Ans2.push_back('1');
      } else if (S[i] == '2' && ~Who) {
        Ans1.push_back('0');
        Ans2.push_back('2');
      } else if (S[i] == '0') {
        Ans1.push_back('0');
        Ans2.push_back('0');
      } else {
        if (~Who) {
          Ans1.push_back('0');
          Ans2.push_back('1');
        } else {
          Ans1.push_back('1');
          Ans2.push_back('0');
          Who = 1;
        }
      }
    }
    cout << Ans1 << "\n" << Ans2 << "\n";
  }
  return 0;
}
