#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    string s1 = "";
    string s2 = "";
    int flag = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '2' && flag == 0) {
        s1 += "1";
        s2 += "1";
      } else if (s[i] == '1' && flag == 0) {
        s1 += "1";
        s2 += "0";
        flag = 1;
      } else if (s[i] == '0') {
        s1 += "0";
        s2 += "0";
      } else if (flag == 1) {
        s1 += "0";
        s2 += s[i];
      }
    }
    cout << s1 << endl;
    cout << s2 << endl;
  }
}
