#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, d, m, k, q, l, i, j, x, y, z, x1, x2, y1, y2, ans;
  cin >> t;
  while (t--) {
    cin >> n;
    string second;
    cin >> second;
    bool flag = false;
    string s1 = "";
    string s2 = "";
    for (i = 0; i < n; i++) {
      if (!flag && second[i] == '2') {
        s1 += '1';
        s2 += '1';
      } else if (!flag && second[i] == '0') {
        s1 += '0';
        s2 += '0';
      } else if (!flag && second[i] == '1') {
        s1 += '1';
        s2 += '0';
        flag = true;
      } else if (flag) {
        s1 += '0';
        s2 += second[i];
      }
    }
    cout << s1 << endl;
    cout << s2 << endl;
  }
  return 0;
}
