#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long N = 2e5 + 5;
long long n;
string s;
void test_case() {
  cin >> n >> s;
  vector<vector<long long>> v(2);
  long long cnt = 0;
  vector<long long> ans;
  for (char c : s) {
    if (c == '0') {
      if (v[1].empty()) {
        ans.push_back(++cnt);
        v[0].push_back(cnt);
      } else {
        ans.push_back(v[1].back());
        v[0].push_back(v[1].back());
        v[1].pop_back();
      }
    } else {
      if (v[0].empty()) {
        ans.push_back(++cnt);
        v[1].push_back(cnt);
      } else {
        ans.push_back(v[0].back());
        v[1].push_back(v[0].back());
        v[0].pop_back();
      }
    }
  }
  cout << cnt << "\n";
  for (long long x : ans) cout << x << ' ';
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    test_case();
  }
  return 0;
}
