#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long n;
string s;
vector<long long> v0, v1;
int32_t main() {
  fast();
  long long t, z;
  cin >> t;
  for (long long z = 1; z < t + 1; z++) {
    cin >> n >> s;
    v0.clear();
    v1.clear();
    vector<long long> ans(n);
    for (long long i = 0; i < n; i++) {
      long long pos = v0.size() + v1.size();
      if (s[i] == '0') {
        if (v1.empty())
          v0.emplace_back(pos);
        else {
          pos = v1.back();
          v1.pop_back();
          v0.emplace_back(pos);
        }
      } else {
        if (v0.empty())
          v1.emplace_back(pos);
        else {
          pos = v0.back();
          v0.pop_back();
          v1.emplace_back(pos);
        }
      }
      ans[i] = pos;
    }
    cout << v0.size() + v1.size() << "\n";
    for (auto i : ans) cout << i + 1 << " ";
    cout << "\n";
  }
}
