#include <bits/stdc++.h>
using namespace std;
int ans[200001];
int main() {
  int _;
  cin >> _;
  while (_--) {
    int n;
    string s1;
    set<int> s[2];
    cin >> n;
    cin >> s1;
    int c = 1;
    for (int i = 0; i < n; i++) {
      int k = s1[i] - '0';
      if (s[k].empty()) {
        ans[i] = c;
        s[1 - k].insert(c++);
      } else {
        int t = *(s[k].begin());
        ans[i] = t;
        s[k].erase(t);
        s[1 - k].insert(t);
      }
    }
    cout << c - 1 << endl;
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
