#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, Mod = 1e9 + 7;
bool OK(long long a, long long k) { return (a * (a + 1) / 2 <= k); }
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int slen = s.length();
    string a, b;
    a.resize(slen);
    b.resize(slen);
    int p = 0;
    for (int i = 0; i < slen; i++) {
      int t = s[i] - '0';
      if (!p) {
        if (t % 2) {
          a[i] = '1';
          b[i] = '0';
          p++;
          continue;
        }
        a[i] = t / 2 + '0';
        b[i] = t / 2 + '0';
        continue;
      }
      b[i] = s[i];
      a[i] = '0';
    }
    cout << a << endl << b << endl;
  }
}
