#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string ss;
    cin >> ss;
    set<int> s[2];
    for (int i = 0; i < n; ++i) {
      s[ss[i] - '0'].insert(i);
    }
    vector<int> ans(n);
    int ansCount = 0;
    int left = n;
    while (left > 0) {
      int count = 0;
      int curr;
      if (s[1].empty()) {
        curr = 0;
      } else if (s[0].empty()) {
        curr = 1;
      } else {
        if (*s[0].begin() < *s[1].begin())
          curr = 0;
        else
          curr = 1;
      }
      int currPos = *s[curr].begin();
      while (true) {
        auto it = s[curr].lower_bound(currPos);
        if (it == s[curr].end()) break;
        ans[*it] = ansCount;
        currPos = *it;
        left--;
        s[curr].erase(it);
        curr = 1 - curr;
      }
      ansCount++;
    }
    cout << ansCount << endl;
    for (auto x : ans) {
      cout << x + 1 << " ";
    }
    cout << endl;
  }
}
