#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long quickpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    vector<int> ans(n), dic(n + 1, -1);
    int now = 1, maxn = 1;
    ans[0] = 1;
    dic[1] = s[0];
    for (int i = 1; i < n; i++) {
      if (s[i] == s[i - 1]) {
        for (now; dic[now] == s[i]; now++)
          ;
        dic[now] = s[i];
        ans[i] = now;
      } else {
        now = 1;
        ans[i] = 1;
        dic[now] = s[i];
      }
    }
    int mm = 0;
    for (int i = 1; i <= n; i++) {
      if (dic[i] != -1) {
        mm = i;
      }
    }
    cout << mm << endl;
    for (int i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
