#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int mxN = 2e2;
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> ans(n);
    vector<int> pos0, pos1;
    for (int i = 0; i < n; i++) {
      int newPos = (int)pos0.size() + (int)pos1.size();
      if (s[i] == '0') {
        if (pos1.empty()) {
          pos0.push_back(newPos);
        } else {
          newPos = pos1.back();
          pos1.pop_back();
          pos0.push_back(newPos);
        }
      } else if (s[i] == '1') {
        if (pos0.empty()) {
          pos1.push_back(newPos);
        } else {
          newPos = pos0.back();
          pos0.pop_back();
          pos1.push_back(newPos);
        }
      }
      ans[i] = newPos + 1;
    }
    cout << ((int)pos0.size() + (int)pos1.size()) << endl;
    for (auto x : ans) cout << x << " ";
    cout << endl;
  }
  return 0;
}
