#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5, LOG = 18;
int depth[MAXN], pa[LOG][MAXN], a[MAXN];
vector<int> adj[MAXN];
void dfs(int now, int par) {
  for (auto nxt : adj[now]) {
    if (nxt == par) continue;
    pa[0][nxt] = now;
    for (int i = 1; i < 18; i++) pa[i][nxt] = pa[i - 1][pa[i - 1][nxt]];
    depth[nxt] = depth[now] + 1;
    dfs(nxt, now);
  }
}
int LCA(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int diff = depth[u] - depth[v];
  for (int i = LOG - 1; i >= 0; i--) {
    if (diff & (1 << i)) u = pa[i][u];
  }
  if (u == v) return u;
  for (int i = 17; i >= 0; i--) {
    if (pa[i][u] != pa[i][v]) {
      u = pa[i][u];
      v = pa[i][v];
    }
  }
  return pa[0][u];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, n;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    string a = "", b = "";
    bool sudah = false;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        a += '0';
        b += '0';
      } else if (s[i] == '1') {
        if (!sudah) {
          a += '1';
          b += '0';
        } else {
          a += '0';
          b += '1';
        }
        sudah = true;
      } else {
        if (!sudah) {
          a += '1';
          b += '1';
        } else {
          a += '0';
          b += '2';
        }
      }
    }
    cout << a << '\n' << b << '\n';
  }
  return 0;
}
