#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
string direc = "URDL";
const long long MOD2 = (long long)998244353 * (long long)998244353;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
char s[200135];
vector<int> vp[10][2];
int t[200135], a[200135];
void fmain(int tid) {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int(j) = 0; (j) < (int)(10); (j)++)
    for (int(z) = 0; (z) < (int)(2); (z)++) vp[j][z].clear();
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    int num = s[i] - '0';
    bool ok = 0;
    for (int j = num + 1; j < 10; j++)
      if (!vp[j][0].empty() || !vp[j][1].empty()) ok = 1;
    if (ok) {
      for (int j = num + 1; j < 10; j++) {
        for (int z : vp[j][0]) vp[j][1].push_back(move(z));
        vp[j][0].clear();
      }
      vp[num][0].push_back(i);
      continue;
    }
    for (int(j) = 0; (j) < (int)(num); (j)++)
      if (!vp[j][1].empty()) ok = 1;
    if (ok)
      vp[num][1].push_back(i);
    else
      vp[num][0].push_back(i);
  }
  for (int(z) = 0; (z) < (int)(2); (z)++) {
    for (int(j) = 0; (j) < (int)(10); (j)++)
      for (int x : vp[j][z]) t[x] = z + 1;
  }
  int cnt = 0;
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (t[i] == 1) {
      a[++cnt] = s[i] - '0';
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (t[i] == 2) {
      a[++cnt] = s[i] - '0';
    }
  for (int(i) = 1; (i) <= (int)(n - 1); (i)++)
    if (a[i] > a[i + 1]) {
      puts("-");
      return;
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++) printf("%d", t[i]);
  puts("");
}
int main() {
  int t = 1;
  scanf("%d", &t);
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
