#include <bits/stdc++.h>
using namespace std;
long long int check(string str, long long int start, long long int n) {
  long long int var = start;
  for (long long int i = start + 1; i < n; i++) {
    if (str[i] != str[i - 1]) {
      var = i;
    } else {
      break;
    }
  }
  return var;
}
int32_t main() {
  long long int x;
  cin >> x;
  while (x--) {
    long long int n;
    cin >> n;
    string str;
    cin >> str;
    long long int cnt = 1;
    long long int temp = check(str, 0, n);
    if (n == 1 || temp == n - 1) {
      cout << 1 << "\n";
      for (long long int i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      cout << "\n";
    } else {
      vector<long long int> arr;
      queue<long long int> pos0, pos1;
      for (long long int i = 0; i < n; i++) {
        if (str[i] == '0') {
          if (!pos1.empty()) {
            long long int val = pos1.front();
            pos1.pop();
            pos0.push(val);
            arr.push_back(val);
          } else {
            pos0.push(cnt);
            arr.push_back(cnt);
            cnt++;
          }
        } else {
          if (!pos0.empty()) {
            long long int val = pos0.front();
            pos0.pop();
            pos1.push(val);
            arr.push_back(val);
          } else {
            pos1.push(cnt);
            arr.push_back(cnt);
            cnt++;
          }
        }
      }
      cout << cnt - 1 << "\n";
      for (auto x : arr) {
        cout << x << " ";
      }
      cout << "\n";
    }
  }
}
