#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int nax = 1e6 + 10;
long long i, j, x, y, k, f, z, cnt;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    stack<long long> one, zero;
    vector<long long> ans;
    long long p = 1;
    for (i = 0; i < n; i++) {
      if (s[i] == '1') {
        if (!zero.empty()) {
          ans.push_back(zero.top());
          one.push(zero.top());
          zero.pop();
        } else {
          ans.push_back(p);
          one.push(p);
          p++;
        }
      } else {
        if (!one.empty()) {
          ans.push_back(one.top());
          zero.push(one.top());
          one.pop();
        } else {
          ans.push_back(p);
          zero.push(p);
          p++;
        }
      }
    }
    cout << p - 1 << endl;
    for (i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
