#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, r;
    cin >> n;
    vector<char> v1;
    vector<char> v2;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
      if (s[i] == '2') {
        v1.push_back('1');
        v2.push_back('1');
      }
      if (s[i] == '1') {
        v1.push_back('1');
        v2.push_back('0');
        for (int j = i + 1; j < n; j++) {
          v1.push_back('0');
          v2.push_back(s[j]);
        }
        break;
      } else if (s[i] == '0') {
        v1.push_back('0');
        v2.push_back('0');
      }
    }
    for (int i = 0; i < v1.size(); i++) {
      cout << v1[i];
    }
    cout << "\n";
    for (int i = 0; i < v2.size(); i++) {
      cout << v2[i];
    }
    cout << "\n";
  }
  return 0;
}
