#include <bits/stdc++.h>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T>
void smin(T& a, T val) {
  if (a > val) a = val;
}
template <class T>
void smax(T& a, T val) {
  if (a < val) a = val;
}
const long long N = 5 * (long long)1e5 + 10;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  bool got = 0;
  for (long long last = 0; last < 10; ++last) {
    vector<long long> v1, v2;
    bool bad = 0;
    long long max_1 = -inf;
    long long min_2 = inf;
    vector<long long> faltu;
    vector<long long> color(n);
    for (long long i = 0; i < n; ++i) {
      long long curr = s[i] - '0';
      if (curr < last) {
        if ((long long)(v1.size()) >= 1) {
          if (!(v1.back() <= curr)) {
            bad = 1;
            break;
          }
        }
        smax(max_1, i);
        color[i] = 1;
        v1.push_back(curr);
      } else if (curr > last) {
        if ((long long)(v2.size()) >= 1) {
          if (!(v2.back() <= curr)) {
            bad = 1;
            break;
          }
        }
        smin(min_2, i);
        color[i] = 2;
        v2.push_back(curr);
      } else {
        faltu.push_back(i);
      }
    }
    for (auto i : faltu) {
      if (i <= max_1 and i >= min_2) {
        bad = 1;
        break;
      } else if (i > max_1) {
        color[i] = 1;
      } else {
        color[i] = 2;
      }
    }
    if (bad) continue;
    for (long long i = 0; i < n; ++i) {
      cout << color[i];
    }
    got = 1;
    return;
  }
  if (!got) {
    cout << "-";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}
