#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e13;
int main() {
  long long int t, n;
  string x;
  cin >> t;
  while (t--) {
    cin >> n >> x;
    string a(n, '0'), b(n, '0');
    long long int l = 0;
    for (long long int i = 0; i < n; i++) {
      if (x[i] == '1') {
        a[i] = '1';
        b[i] = '0';
        for (long long int j = i + 1; j < n; j++) b[j] = x[j];
        break;
      } else
        a[i] = b[i] = '0' + (x[i] - '0') / 2;
    }
    cout << a << endl << b << endl;
  }
  return 0;
}
