#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e4 + 10;
int a[maxn], b[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int first = 1;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      char ch;
      cin >> ch;
      if (first) {
        if (ch == '2')
          a[i] = b[i] = 1;
        else if (ch == '1') {
          if (first) {
            a[i] = 1;
            b[i] = 0;
            first = 0;
          }
        } else
          a[i] = b[i] = 0;
      } else {
        a[i] = 0;
        b[i] = ch - '0';
      }
    }
    for (int i = 0; i < n; i++) cout << a[i];
    cout << endl;
    for (int i = 0; i < n; i++) cout << b[i];
    cout << endl;
  }
  return 0;
}
