#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
char s[MAXN];
int ans[MAXN];
bool check(deque<int> &a, deque<int> &b, int n) {
  if (a.size() + b.size() < n) return false;
  assert(a.size() + b.size() == n);
  for (int i = 0; i + 1 < (int)a.size(); i++) {
    if (s[a[i]] > s[a[i + 1]]) return false;
  }
  for (int i = 0; i + 1 < (int)b.size(); i++) {
    if (s[b[i]] > s[b[i + 1]]) return false;
  }
  if (!a.empty() && !b.empty() && s[a.back()] > s[b.front()]) return false;
  return true;
}
void output(deque<int> &a, deque<int> &b, int n) {
  for (auto &x : a) ans[x] = 1;
  for (auto &x : b) ans[x] = 2;
  for (int i = 1; i <= n; i++) printf("%d", ans[i]);
  printf("\n");
}
void solve_test() {
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  bool done = false;
  for (char d = '0'; d <= '9'; d++) {
    deque<int> sol1, sol2;
    int last_small = 0, first_big = n + 1;
    for (int i = 1; i <= n; i++) {
      if (s[i] < d) {
        sol1.push_back(i);
        last_small = i;
      } else if (s[i] > d) {
        sol2.push_back(i);
        if (first_big == n + 1) first_big = i;
      }
    }
    for (int i = last_small + 1; i <= n; i++) {
      if (s[i] == d) sol1.push_back(i);
    }
    for (int i = 1; i < min(last_small, first_big); i++) {
      if (s[i] == d) sol2.push_front(i);
    }
    if (check(sol1, sol2, n)) {
      output(sol1, sol2, n);
      done = true;
      break;
    }
  }
  if (!done) puts("-");
}
int main() {
  int tests;
  scanf("%d", &tests);
  while (tests--) {
    solve_test();
  }
  return 0;
}
