#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
const int N = 2e5 + 10;
int n;
char s[N];
int a[N];
int f[2];
int vis[N];
char ans[N];
void RUN() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = s[i] - '0';
  }
  for (int d = 0; d <= 9; ++d) {
    for (int i = 1; i <= n; ++i) {
      vis[i] = 0;
    }
    int p = -1;
    for (int i = n; i >= 1; --i) {
      if (a[i] < d) break;
      if (a[i] == d) {
        p = i;
        vis[i] = 1;
      }
    }
    bool F = true;
    int now = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i] < d) {
        if (a[i] < now) {
          F = false;
          break;
        }
        now = a[i];
        vis[i] = 1;
      }
    }
    if (!F) continue;
    now = 0;
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        if (a[i] < now) {
          F = false;
          break;
        }
        now = a[i];
        vis[i] = 2;
      }
    }
    if (!F) continue;
    for (int i = 1; i <= n; ++i) {
      printf("%d", vis[i]);
    }
    puts("");
    return;
  }
  puts("-");
}
int main() {
  int _T;
  scanf("%d", &_T);
  while (_T--) {
    RUN();
  }
  return 0;
}
