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