#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<long long> a(n);
    queue<int> zeros, ones;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        if (!ones.empty()) {
          int last = ones.front();
          a[i] = last;
          ones.pop();
          zeros.push(last);
        } else {
          a[i] = ++cnt;
          zeros.push(cnt);
        }
      } else {
        if (!zeros.empty()) {
          int last = zeros.front();
          a[i] = last;
          zeros.pop();
          ones.push(last);
        } else {
          a[i] = ++cnt;
          ones.push(cnt);
        }
      }
    }
    cout << cnt << '\n';
    for (auto i : a) cout << i << " ";
    cout << '\n';
  }
  return 0;
}
