#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, t, flag;
  char ch, cha, chb;
  cin >> t;
  while (t--) {
    flag = 0;
    string s, a, b;
    cin >> n;
    cin >> s;
    a.push_back('1');
    b.push_back('1');
    for (i = 1; i < n; i++) {
      if (flag == 1) {
        a.push_back('0');
        b.push_back(s[i]);
      } else if (flag == 2) {
        a.push_back(s[i]);
        b.push_back('0');
      } else {
        ch = '0' + (s[i] - '0') / 2;
        a.push_back(ch);
        ch = s[i] - ch + '0';
        b.push_back(ch);
      }
      if (a[i] != b[i] && flag == 0) {
        flag = a[i] > b[i] ? 1 : 2;
      }
    }
    cout << a << endl << b << endl;
  }
}
