#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2, mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    string s1, s2;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (cnt) {
        if (s[i] == '2')
          s1 += '0', s2 += '2';
        else if (s[i] == '0')
          s1 += '0', s2 += '0';
        else
          s1 += '0', s2 += '1';
      } else {
        if (s[i] == '2')
          s1 += '1', s2 += '1';
        else if (s[i] == '0')
          s1 += '0', s2 += '0';
        else
          cnt++, s1 += '1', s2 += '0';
      }
    }
    cout << s1 << "\n" << s2;
    cout << "\n";
  }
  return 0;
}
