#include <bits/stdc++.h>
using namespace std;
long long dx[8] = {+1, +1, +1, 0, 0, -1, -1, -1};
long long dy[8] = {+1, 0, -1, +1, -1, +1, 0, -1};
void input_File() {}
void solve() {
  long long n;
  set<long long> st[2];
  string s;
  cin >> n >> s;
  for (long long i = 0; i < n; i++) st[s[i] - '0'].insert(i);
  vector<long long> res(n, 0);
  long long round = 1;
  bool flag = 0;
  long long curr = -1;
  while (!st[0].empty() and !st[1].empty()) {
    long long num1 = *st[1].begin();
    long long num0 = *st[0].begin();
    if (num1 < num0)
      flag = 1;
    else
      flag = 0;
    curr = min(num1, num0);
    res[curr] = round;
    st[flag].erase(curr);
    flag = !flag;
    while (true) {
      if (st[flag].upper_bound(curr) == st[flag].end()) break;
      curr = *st[flag].upper_bound(curr);
      res[curr] = round;
      st[flag].erase(curr);
      flag = !flag;
    }
    round++;
  }
  for (long long i = 0; i < 2; i++)
    for (auto &x : st[i]) res[x] = round, round++;
  cout << --round << "\n";
  for (long long &it : res) cout << it << " ";
  cout << "\n";
}
signed main() {
  input_File();
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long isTestCasePresent = 1;
  if (isTestCasePresent == 0) {
    long long t = 1;
    while (t--) {
      solve();
    }
  } else {
    long long t;
    cin >> t;
    while (t--) {
      solve();
    }
  }
  return 0;
}
