#include <bits/stdc++.h>
using namespace std;
void solve(string s, int n) {
  vector<char> a(n);
  vector<char> b(n);
  a[0] = '1';
  b[0] = '1';
  bool foundOne = false;
  for (int i = 1; i < n; i++) {
    if (s[i] == '0') {
      a[i] = '0';
      b[i] = '0';
    } else if (s[i] == '1') {
      if (!foundOne) {
        a[i] = '1';
        b[i] = '0';
      } else {
        a[i] = '0';
        b[i] = '1';
      }
      foundOne = true;
    } else {
      if (!foundOne) {
        a[i] = '1';
        b[i] = '1';
      } else {
        a[i] = '0';
        b[i] = '2';
      }
    }
  }
  cout << string(a.begin(), a.end()) << endl;
  cout << string(b.begin(), b.end()) << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    solve(s, n);
  }
}
