#include <bits/stdc++.h>
using namespace std;
void find(string s, long long n) {
  int flag = 0;
  string s1 = "", s2 = "";
  for (long long i = 0; i < n; i++) {
    if (s[i] == '2') {
      s1 = s1 + '1';
      s2 = s2 + '1';
    }
    if (s[i] == '1') {
      s1 = s1 + '1';
      s2 = s2 + '0';
      break;
    }
    if (s[i] == '0') {
      s1 = s1 + '0';
      s2 = s2 + '0';
    }
  }
  for (long long i = 0; i < s1.length(); i++) cout << s1[i];
  for (long long i = s1.length(); i < s.length(); i++) cout << "0";
  cout << "\n";
  for (long long i = 0; i < s2.length(); i++) cout << s2[i];
  for (long long i = s2.length(); i < s.length(); i++) cout << s[i];
}
void solve(int t) {
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    find(s, n);
    if (t != 0) cout << "\n";
  }
}
int main() {
  int t;
  cin >> t;
  solve(t);
  return 0;
}
