#include <bits/stdc++.h>
using namespace std;
int main() {
  int count;
  cin >> count;
  for (int k = 0; k < count; ++k) {
    int n;
    cin >> n;
    vector<int> vec;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i) {
      vec.push_back(s[i] - '0');
    }
    vector<int> res1;
    vector<int> res2;
    bool added = false;
    for (int i = 0; i < n; ++i) {
      if (vec[i] == 0) {
        res1.push_back(0);
        res2.push_back(0);
      }
      if (vec[i] == 2) {
        if (!added) {
          res1.push_back(1);
          res2.push_back(1);
        } else {
          res1.push_back(0);
          res2.push_back(2);
        }
      }
      if (vec[i] == 1) {
        if (!added) {
          res1.push_back(1);
          res2.push_back(0);
          added = true;
        } else {
          res1.push_back(0);
          res2.push_back(1);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << res1[i];
    }
    cout << '\n';
    for (int i = 0; i < n; ++i) {
      cout << res2[i];
    }
    cout << '\n';
  }
  return 0;
}
