#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    long long int k = 0, a[n], i, num[2] = {0};
    vector<long long int> n0, n1;
    for (i = 0; i < n; i++) {
      if (s[i] - '0' == 1) {
        if (num[1] == 0) {
          k++;
          num[0]++;
          a[i] = k;
          n0.push_back(k);
        } else {
          a[i] = n1[n1.size() - 1];
          n1.pop_back();
          n0.push_back(a[i]);
          num[1]--;
          num[0]++;
        }
      } else {
        if (num[0] == 0) {
          k++;
          num[1]++;
          a[i] = k;
          n1.push_back(k);
        } else {
          a[i] = n0[n0.size() - 1];
          n0.pop_back();
          n1.push_back(a[i]);
          num[0]--;
          num[1]++;
        }
      }
    }
    cout << k << endl;
    for (i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
