#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int m = 0; m < t; m++) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int ch;
    int i = 1;
    string a, b;
    a = a + '1';
    b = b + '1';
    for (; i < n; i++) {
      ch = (int)str.at(i) - 48;
      if (ch == 1) {
        a = a + '0';
        b = b + '1';
        break;
      }
      if (ch == 0) {
        a = a + '0';
        b = b + '0';
      } else {
        a = a + '1';
        b = b + '1';
      }
    }
    for (i++; i < n; i++) {
      ch = (int)str.at(i) - 48;
      if (ch == 0)
        a = a + '0';
      else if (ch == 1)
        a = a + '1';
      else
        a = a + '2';
      b = b + '0';
    }
    cout << a << "\n" << b << "\n";
  }
}
