#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238460;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int max(long long int a, long long int b) {
  if (a > b)
    return a;
  else
    return b;
}
long long int min(long long int a, long long int b) {
  if (a < b)
    return a;
  else
    return b;
}
long long int power(long long int a, long long int n) {
  long long int res = 1;
  while (n) {
    if (n % 2 == 0) {
      a *= a;
      n /= 2;
    } else {
      res *= a;
      n--;
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, j, k, p = 1;
    cin >> n;
    string s;
    cin >> s;
    vector<long long int> a(n, 0);
    vector<long long int> last;
    queue<long long int> zero, one;
    for (i = 0; i < s.size(); i++) {
      k = s[i] - '0';
      if (k == 0) {
        if (!one.empty()) {
          j = one.front();
          one.pop();
          a[i] = j;
          zero.push(j);
        } else {
          a[i] = p;
          p++;
          zero.push(a[i]);
        }
      } else {
        if (!zero.empty()) {
          j = zero.front();
          zero.pop();
          a[i] = j;
          one.push(j);
        } else {
          a[i] = p;
          p++;
          one.push(a[i]);
        }
      }
    }
    cout << *max_element(a.begin(), a.end()) << '\n';
    for (i = 0; i < s.size(); i++) {
      cout << a[i] << " ";
    }
    cout << '\n';
  }
  return 0;
}
