#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<long long> ans(n, -1);
  set<long long> st[2];
  long long f = s[0] - '0';
  for (long long i = 0; i < n; ++i) {
    st[s[i] - '0'].insert(i);
  }
  long long cur = -1;
  long long c = 1;
  while (true) {
    if (!st[0].size() || !st[1].size()) break;
    if (*st[0].begin() < *st[1].begin()) {
      cur = *st[0].begin();
      f = 0;
    } else {
      cur = *st[1].begin();
      f = 1;
    }
    while (true) {
      auto it = st[f].lower_bound(cur);
      if (it == st[f].end())
        break;
      else {
        ans[*it] = c;
        cur = *it;
        st[f].erase(it);
        f ^= 1;
      }
    }
    c++;
  }
  for (long long i = 0; i < n; ++i) {
    if (ans[i] == -1) ans[i] = c++;
  }
  cout << c - 1 << '\n';
  for (long long i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1;
  cin >> T;
  for (long long i = 1; i <= T; ++i) {
    solve();
  }
  return 0;
}
