#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tpl = tuple<int, int, int>;
using pcc = pair<char, char>;
const int inf = 2e9;
const int mod = 1e9 + 7;
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int kr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int kc[] = {-2, -2, -1, 1, 2, 2, -1, 1};
int dgr[] = {-1, -1, 1, 1};
int dgc[] = {1, -1, -1, 1};
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, cnt = 0;
    cin >> n;
    string str;
    cin >> str;
    queue<int> zero, one;
    vector<int> ans;
    for (char ch : str) {
      if (ch == '0') {
        if (!one.empty()) {
          int k = one.front();
          one.pop();
          ans.push_back(k);
          zero.push(k);
        } else {
          ans.push_back(++cnt);
          zero.push(cnt);
        }
      } else {
        if (!zero.empty()) {
          int k = zero.front();
          zero.pop();
          ans.push_back(k);
          one.push(k);
        } else {
          ans.push_back(++cnt);
          one.push(cnt);
        }
      }
    }
    cout << cnt << endl;
    for (int x : ans) cout << x << ' ';
    cout << endl;
  }
  return 0;
}
