#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 10;
int a[N], b[N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    a[1] = b[1] = 1;
    bool flag = false;
    char ch;
    scanf(" %c", &ch);
    for (int i = 2; i <= n; i++) {
      scanf(" %c", &ch);
      if (flag) {
        b[i] = 0;
        a[i] = ch - '0';
      } else {
        if (ch == '0' || ch == '2')
          a[i] = b[i] = (ch - '0') / 2;
        else {
          flag = true;
          a[i] = 0;
          b[i] = 1;
        }
      }
    }
    for (int i = 1; i <= n; i++) printf("%d", a[i]);
    puts("");
    for (int i = 1; i <= n; i++) printf("%d", b[i]);
    puts("");
  }
  return 0;
}
