#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;
    map<char, vector<long long>> M;
    map<long long, long long> solMap;
    long long cnt = 0;
    for (long long i = 0; i < n; i++) {
      int num = s[i] - '0';
      num = (num + 1) % 2;
      if (M[(char)('0' + num)].size() == 0) {
        cnt++;
        M[(char)('0' + ((num + 1) % 2))].push_back(cnt);
        solMap[i] = cnt;
      } else {
        long long sz = M[(char)('0' + num)].size();
        long long val = M[(char)('0' + num)][sz - 1];
        solMap[i] = val;
        M[(char)('0' + num)].pop_back();
        M[(char)('0' + ((num + 1) % 2))].push_back(val);
      }
    }
    cout << cnt << endl;
    for (long long i = 0; i < n; i++) cout << solMap[i] << " ";
    cout << endl;
  }
  return 0;
}
