#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y);
long long int gcd(long long int a, long long int b);
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    vector<long long int> lz, lo, ans;
    long long int c = 0;
    for (long long int i = 0; i < n; i++) {
      if (s[i] == '0') {
        if (lo.size() == 0) {
          c++;
          lz.push_back(c);
          ans.push_back(c);
        } else {
          long long int l = lo.back();
          lo.pop_back();
          ans.push_back(l);
          lz.push_back(l);
        }
      } else {
        if (lz.size() == 0) {
          c++;
          lo.push_back(c);
          ans.push_back(c);
        } else {
          long long int l = lz.back();
          lz.pop_back();
          ans.push_back(l);
          lo.push_back(l);
        }
      }
    }
    cout << c << "\n";
    for (auto i : ans) cout << i << " ";
    cout << "\n";
  }
}
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x %= 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
