#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    getline(cin >> ws, s);
    string one = "1", two = "1";
    int prevOne = 1, prevTwo = 1;
    for (int i = 1; i < n; i++) {
      int num = s[i] - '0';
      if (prevOne == prevTwo) {
        if (num == 2) {
          one += '1';
          two += '1';
          prevOne = 1;
          prevTwo = 1;
        } else if (num == 1) {
          one += '1';
          two += '0';
          prevOne = 1;
          prevTwo = 0;
        } else {
          one += '0';
          two += '0';
          prevOne = '0';
          prevTwo = '0';
        }
      } else {
        for (int j = i; j < n; j++) {
          one += '0';
          two += s[j];
        }
        break;
      }
    }
    cout << one << "\n" << two << "\n";
  }
}
