#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long ans = 0;
    long long cnt[2] = {0};
    set<long long> st[2];
    long long ptr = 0;
    vector<long long> a;
    for (char c : s) {
      long long val = c - '0';
      if (cnt[!val] == 0) {
        ++ptr;
        cnt[val]++;
        st[val].insert(ptr);
        a.push_back(ptr);
        ++ans;
      } else {
        cnt[!val]--;
        long long ind = *st[!val].begin();
        st[!val].erase(st[!val].begin());
        st[val].insert(ind);
        a.push_back(ind);
        cnt[val]++;
      }
    }
    cout << ans << '\n';
    for (long long x : a) {
      cout << x << " ";
    }
    cout << '\n';
  }
  return 0;
}
