#include <bits/stdc++.h>
using namespace std;
int t, n, a[50007], b[50007], c[50007];
string str;
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> n >> str;
    for (int i = 0; i < n; ++i) {
      a[i] = str[i] - '0';
    }
    bool flag = 0;
    for (int i = 0; i < n; ++i) {
      if (flag == 0) {
        if (a[i] == 1) {
          b[i] = 1;
          flag = 1;
        } else {
          b[i] = a[i] / 2;
        }
      } else {
        b[i] = 0;
      }
    }
    for (int i = 0; i < n; ++i) {
      c[i] = (3 + a[i] - b[i]) % 3;
    }
    for (int i = 0; i < n; ++i) {
      cout << b[i];
    }
    cout << endl;
    for (int i = 0; i < n; ++i) {
      cout << c[i];
    }
    cout << endl;
  }
  return 0;
}
