#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 10;
const int mod = 1e9 + 7;
set<int> st;
vector<int> vt;
long long n, ans, cnt;
long long a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t-- > 0) {
    cin >> n;
    string s, a, b;
    cin >> s;
    int g = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '2') {
        if (g == 0) {
          a.push_back('1');
          b.push_back('1');
        } else {
          a.push_back('0');
          b.push_back('2');
        }
      } else if (s[i] == '1') {
        if (g == 0) {
          a.push_back('1');
          b.push_back('0');
          g = 1;
        } else {
          b.push_back('1');
          a.push_back('0');
        }
      } else if (s[i] == '0') {
        a.push_back('0');
        b.push_back('0');
      }
    }
    cout << a << "\n" << b << endl;
  }
  return 0;
}
