#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    scanf("%d", &n);
    string w, s1, s2;
    cin >> w;
    s1 = s2 = w;
    bool f = true;
    for (int i = 0; i < n; i++) {
      if (w[i] == '0') {
        s1[i] = '0';
        s2[i] = '0';
      }
      if (w[i] == '1') {
        if (f) {
          s2[i] = '1';
          s1[i] = '0';
          f = false;
        } else {
          s1[i] = '1';
          s2[i] = '0';
        }
      }
      if (w[i] == '2') {
        if (!f) {
          s1[i] = '2';
          s2[i] = '0';
        } else
          s1[i] = s2[i] = '1';
      }
    }
    cout << s1 << endl << s2 << endl;
  }
}
