#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    int ans[n];
    stack<int> s1;
    stack<int> s2;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        if (s2.empty()) {
          count++;
          s1.push(count);
        } else {
          int x = s2.top();
          s2.pop();
          s1.push(x);
        }
        ans[i] = s1.top();
      } else {
        if (s1.empty()) {
          count++;
          s2.push(count);
        } else {
          int x = s1.top();
          s1.pop();
          s2.push(x);
        }
        ans[i] = s2.top();
      }
    }
    int *maxi = max_element(ans, ans + n);
    cout << *maxi << endl;
    for (int i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
}
