#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long i, j;
long long temp;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    vector<pair<long long, long long>> a;
    for (i = 0; i < n; i++) {
      temp = s[i] - '0';
      a.push_back(make_pair(temp, i));
    }
    sort(a.begin(), a.end());
    long long ans[n];
    memset(ans, 0, sizeof(ans));
    long long b = n;
    vector<long long> t1;
    long long bflag = 0, num, ptr;
    for (i = 1; i < n; i++) {
      if (bflag == 1) {
        if (a[i].first != num)
          break;
        else {
          if (a[i].second >= ptr) {
            t1.push_back(a[i].second);
            ans[a[i].second] = 1;
            ptr = a[i].second;
          }
        }
      }
      if (a[i].second < a[i - 1].second) {
        b = i;
        {
          bflag = 1;
          num = a[i].first;
          ptr = a[i - 1].second;
        }
      }
    }
    vector<long long> t2;
    long long flag = 0;
    for (i = b; i < n; i++) {
      if (ans[a[i].second] != 1) {
        t2.push_back(a[i].second);
      }
    }
    for (i = 1; i < t2.size(); i++) {
      if (t2[i] < t2[i - 1]) {
        cout << "-" << '\n';
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      for (i = 0; i < b; i++) {
        ans[a[i].second] = 1;
      }
      for (i = b; i < n; i++) {
        if (ans[a[i].second] == 0) ans[a[i].second] = 2;
      }
      for (i = 0; i < n; i++) cout << ans[i];
      cout << '\n';
    }
  }
  return 0;
}
