#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, i, j, k, l, n, m;
  cin >> t;
  while (t--) {
    cin >> n;
    string str;
    cin >> str;
    k = 0;
    l = 0;
    m = 0;
    vector<int> res(n), on, ze;
    for (i = 0; i < n; i++) {
      if (str[i] == '1') {
        if (k > 0) {
          k--;
          res[i] = ze.back();
          ze.pop_back();
          on.push_back(res[i]);
          l++;
        } else {
          m++;
          res[i] = m;
          l++;
          on.push_back(m);
        }
      } else {
        if (l > 0) {
          l--;
          res[i] = on.back();
          on.pop_back();
          ze.push_back(res[i]);
          k++;
        } else {
          m++;
          res[i] = m;
          ze.push_back(m);
          k++;
        }
      }
    }
    cout << m << endl;
    for (i = 0; i < n; i++) cout << res[i] << " ";
    cout << endl;
  }
  return 0;
}
