#include <bits/stdc++.h>
using namespace std;
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 power(long long int x, long long int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
long long int modpower(long long int x, long long int n, long long int M) {
  int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long int mmi(long long int n, long long int M) {
  return modpower(n, M - 2, M);
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a;
    cin >> a;
    int c = 0;
    vector<int> v;
    set<int> s1;
    set<int> s0;
    for (long long int i = 0; i < n; i++) {
      if (a[i] == '1') {
        if (s0.empty()) {
          c++;
          v.push_back(c);
          s1.insert(c);
        } else {
          int x = *s0.begin();
          v.push_back(x);
          s1.insert(x);
          s0.erase(s0.begin());
        }
      } else {
        if (s1.empty()) {
          c++;
          v.push_back(c);
          s0.insert(c);
        } else {
          int x = *s1.begin();
          v.push_back(x);
          s0.insert(x);
          s1.erase(s1.begin());
        }
      }
    }
    cout << c << "\n";
    for (long long int i = 0; i < v.size(); i++) cout << v[i] << " ";
    cout << "\n";
  }
}
