#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  char inp[n];
  char str[n];
  char str1[n];
  cin >> inp;
  str[0] = '1';
  str1[0] = '1';
  int ctr = 0;
  for (int i = 1; i < n; i++) {
    if ((inp[i] == '0' && ctr == 0)) {
      str[i] = '0';
      str1[i] = '0';
    } else if (inp[i] == '2' && ctr == 0) {
      str[i] = '1';
      str1[i] = '1';
    } else if (inp[i] == '1' && ctr == 0) {
      ctr++;
      str[i] = '1';
      str1[i] = '0';
    } else if (ctr == 1 && inp[i] == '0') {
      str[i] = '0';
      str1[i] = '0';
    } else if (ctr == 1 && inp[i] == '1') {
      str[i] = '0';
      str1[i] = '1';
    } else if (ctr == 1 && inp[i] == '2') {
      str[i] = '0';
      str1[i] = '2';
    }
  }
  for (int i = 0; i < n; i++) cout << str[i];
  cout << "\n";
  for (int i = 0; i < n; i++) cout << str1[i];
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
}
