#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1E9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int z;
  cin >> z;
  while (z--) {
    int n, x = 0;
    cin >> n;
    string s1, a(n, '0'), s(n, '0');
    cin >> s1;
    a[0] = '1';
    s[0] = '1';
    for (int i = 1; i < n; i++) {
      if (s1[i] == '2') {
        if (x == 0)
          a[i] = '1';
        else
          a[i] = '0';
      } else if (s1[i] == '1') {
        if (x == 0) {
          a[i] = '1';
          x++;
        } else
          a[i] = '0';
      } else
        a[i] = '0';
      s[i] = s1[i] - a[i] + '0';
    }
    cout << a << endl;
    cout << s << endl;
  }
  return 0;
}
