#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1, arr[n];
    vector<int> x, y;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        if (y.empty()) {
          x.push_back(ans);
          arr[i] = ans;
          ans++;
        } else {
          x.push_back(y.back());
          arr[i] = y.back();
          y.pop_back();
        }
      } else {
        if (x.empty()) {
          y.push_back(ans);
          arr[i] = ans;
          ans++;
        } else {
          y.push_back(x.back());
          arr[i] = x.back();
          x.pop_back();
        }
      }
    }
    cout << ans - 1 << "\n";
    for (int i = 0; i < n; i++) {
      cout << arr[i] << " ";
    }
    cout << "\n";
  }
  return 0;
}
