#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    int A[2];
    A[0] = A[1] = 0;
    map<int, vector<int> > m;
    vector<int> ans(n);
    int i, x = 1;
    for (i = 0; i < n; i++) {
      if (s[i] == '1') {
        if (A[0] == 0) {
          A[1]++;
          ans[i] = x;
          m[1].push_back(x++);
        } else {
          A[0]--;
          A[1]++;
          ans[i] = m[0].back();
          m[1].push_back(m[0].back());
          m[0].pop_back();
        }
      } else {
        if (A[1] == 0) {
          A[0]++;
          ans[i] = x;
          m[0].push_back(x++);
        } else {
          A[1]--;
          A[0]++;
          ans[i] = m[1].back();
          m[0].push_back(m[1].back());
          m[1].pop_back();
        }
      }
    }
    cout << A[0] + A[1] << '\n';
    for (i = 0; i < n; i++) cout << ans[i] << " ";
    cout << '\n';
  }
  return 0;
}
