#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const double pi = acos(-1);
vector<long long> ft(1, 1LL);
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<int> v[2];
  vector<int> ans(n);
  for (long long i = 0; i < n; i++) {
    if (v[(s[i] - '0') ^ 1].size() == 0) {
      int c = v[0].size() + v[1].size() + 1;
      v[s[i] - '0'].push(c);
      ans[i] = c;
    } else
      ans[i] = v[(s[i] - '0') ^ 1].top(),
      v[(s[i] - '0')].push(v[(s[i] - '0') ^ 1].top()),
      v[(s[i] - '0') ^ 1].pop();
  }
  cout << v[0].size() + v[1].size() << '\n';
  for (auto i : ans) cout << i << " ";
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
