#include <bits/stdc++.h>
using namespace std;
int a[200005];
set<int> s0, s1;
int main() {
  int t;
  cin >> t;
  while (t--) {
    s0.clear(), s1.clear();
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      char x;
      cin >> x;
      if (x == '0') {
        if (s0.empty()) {
          s1.insert(++ans);
          a[i] = ans;
        } else {
          s1.insert(*s0.begin());
          a[i] = *s0.begin();
          s0.erase(s0.begin());
        }
      } else if (x == '1') {
        if (s1.empty()) {
          s0.insert(++ans);
          a[i] = ans;
        } else {
          s0.insert(*s1.begin());
          a[i] = *s1.begin();
          s1.erase(s1.begin());
        }
      }
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
