#include <bits/stdc++.h>
using namespace std;
int t, n;
char x[50005];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%s", &n, x);
    for_each(x, x + n, [](char& i) { i -= '0'; });
    int fi = find(x, x + n, 1) - x;
    for (int i = 0; i < fi; i++) printf("%d", x[i] / 2);
    for (int i = fi; i < n; i++) printf("%d", i == fi);
    puts("");
    for (int i = 0; i < fi; i++) printf("%d", x[i] / 2);
    for (int i = fi; i < n; i++) printf("%d", x[i] - (i == fi));
    puts("");
  }
}
