#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    string p;
    cin >> n;
    cin >> p;
    string q;
    string r;
    q += "1";
    r += "1";
    int i = 1;
    while (i < n && (p[i] != '1')) {
      if (p[i] == '0') {
        q += "0";
        r += "0";
      } else {
        q += "1";
        r += "1";
      }
      i++;
    }
    if (i != n) {
      q += "1";
      r += "0";
      i++;
      while (i < n) {
        q += "0";
        string k(1, p[i]);
        r += k;
        i++;
      }
    }
    cout << q << endl << r << endl;
  }
}
