#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    char s[100000], a[100000] = {0}, b[100000] = {0};
    int n;
    cin >> n;
    cin >> s;
    int i, j;
    for (i = 0; i < n; i++) {
      if (s[i] == '1') {
        a[i] = '1';
        b[i] = '0';
        for (j = i + 1; j < n; j++) {
          a[j] = '0';
          b[j] = s[j];
        }
        break;
      } else {
        if (s[i] == '2') {
          a[i] = '1';
          b[i] = '1';
        } else {
          a[i] = '0';
          b[i] = '0';
        }
      }
    }
    a[n] = '\0';
    b[n] = '\0';
    cout << a << endl;
    cout << b << endl;
  }
  return 0;
}
