#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
string str;
set<int> s1, s0;
int ans[maxn];
int main() {
  int t, n;
  scanf("%d", &t);
  while (t--) {
    s1.clear(), s0.clear();
    scanf("%d", &n);
    cin >> str;
    int num = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] == '0') {
        if (s1.empty()) {
          s0.insert(++num);
          ans[i] = num;
        } else {
          ans[i] = *s1.begin();
          s0.insert(*s1.begin());
          s1.erase(*s1.begin());
        }
      }
      if (str[i] == '1') {
        if (s0.empty()) {
          s1.insert(++num);
          ans[i] = num;
        } else {
          ans[i] = *s0.begin();
          s1.insert(*s0.begin());
          s0.erase(*s0.begin());
        }
      }
    }
    cout << num << endl;
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
