#include <bits/stdc++.h>
long long mod = 1e9;
long long MOD = 1e18;
using namespace std;
bool comp(const pair<int, int>& p, const pair<int, int>& q) {
  return (p.first < q.first);
}
bool comp2(const pair<int, int>& p, const pair<int, int>& q) {
  if (p.second != q.second) return (p.second < q.second);
  return (p.first < q.first);
}
long long pp(long long a, long long b) {
  long long t = 1;
  while (b) {
    if (b & 1) t = (t * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return t;
}
bool isprime(int n) {
  int i = 2;
  if (n == 1) return true;
  if (n == 2) return true;
  for (; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long lcd(long long n, long long m) {
  if (n > m) swap(m, n);
  if (m % n == 0)
    return m;
  else {
    int p = n + n;
    while (1) {
      if (p % m == 0)
        return p;
      else
        p = (n + p) % MOD;
    }
  }
}
bool getans(long long left, long long min_left, long long right,
            long long min_right) {
  if (left) {
    if (min_left == min_right)
      return true;
    else if (min_left < min_right) {
      if (right >= (min_right - min_left)) {
        return true;
      }
    } else if (min_left > min_right) {
      if (left - 1 >= (min_left - min_right - 1)) {
        return true;
      }
    }
  } else if (right) {
    if (min_left == min_right)
      return true;
    else if (min_right > min_left) {
      if (right - 1 >= (min_right - min_left - 1)) {
        return true;
      }
    } else if (min_right < min_left) {
      if (left >= (min_left - min_right)) {
        return true;
      }
    }
  } else if (left == 0 && min_left == 0 && min_right == 0)
    return true;
  return false;
}
int main() {
  int cs;
  cin >> cs;
  while (cs--) {
    int n, t = 0;
    cin >> n;
    char s[n + 1], p[n + 1], q[n + 1];
    cin >> s;
    int i;
    for (i = 0; i < n; i++) {
      int d = s[i] - '0';
      if (d == 0) {
        p[i] = '0';
        q[i] = '0';
      } else if (d == 2) {
        if (t == 1 && i != 0) {
          p[i] = '2';
          q[i] = '0';
        } else {
          p[i] = '1';
          q[i] = '1';
        }
      } else {
        if (t) {
          p[i] = '1';
          q[i] = '0';
        } else {
          p[i] = '0';
          q[i] = '1';
          t = 1;
        }
      }
    }
    p[i] = '\0';
    q[i] = '\0';
    cout << p << endl << q << endl;
  }
}
