#include <bits/stdc++.h>
using namespace std;
set<pair<int, pair<int, int> > > all;
int val[200005];
char str[200005];
int answer[200005][2], cnt, n;
int second[4 * 200005];
void modify(int pos, int val, int id = 1, int l = 0, int r = n) {
  if (r - l < 2) {
    second[id] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos < mid)
    modify(pos, val, 2 * id, l, mid);
  else
    modify(pos, val, 2 * id + 1, mid, r);
  second[id] = second[2 * id] + second[2 * id + 1];
}
int sum(int b, int e, int id = 1, int l = 0, int r = n) {
  if (b >= r || e <= l) return 0;
  if (l >= b && r <= e) return second[id];
  int mid = (l + r) >> 1;
  return sum(b, e, 2 * id, l, mid) + sum(b, e, 2 * id + 1, mid, r);
}
int dan(int pos) {
  if (pos >= n - 1 || sum(pos + 1, n) == n - 1 - pos) return -1;
  if (sum(pos + 1, pos + 2) == 0) return pos + 1;
  int l = pos + 1, r = n - 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (sum(pos + 1, mid + 1) == mid - pos)
      l = mid;
    else
      r = mid;
  }
  return r;
}
int bam(int pos) {
  if (pos <= 0 || sum(0, pos) == pos) return -1;
  if (sum(pos - 1, pos) == 0) return pos - 1;
  int l = 0, r = pos - 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (sum(mid, pos) == pos - mid)
      r = mid;
    else
      l = mid;
  }
  return l;
}
int used[200005];
int main() {
  int i;
  scanf("%d", &n);
  scanf("%s", str);
  for (i = 0; i < n; i++) scanf("%d", &val[i]);
  for (i = 0; i < n - 1; i++)
    if (str[i] != str[i + 1])
      all.insert(make_pair(abs(val[i] - val[i + 1]), make_pair(i, i + 1)));
  while (all.size() > 0) {
    pair<int, pair<int, int> > now = *(all.begin());
    all.erase(all.begin());
    int u = now.second.first, v = now.second.second;
    if (used[u] || used[v]) continue;
    answer[cnt][0] = u;
    answer[cnt++][1] = v;
    used[u] = used[v] = 1;
    modify(u, 1);
    modify(v, 1);
    int lf = bam(u), rt = dan(v);
    if (lf == -1 || rt == -1 || str[lf] == str[rt]) continue;
    all.insert(make_pair(abs(val[lf] - val[rt]), make_pair(lf, rt)));
  }
  printf("%d\n", cnt);
  for (i = 0; i < cnt; i++)
    printf("%d %d\n", answer[i][0] + 1, answer[i][1] + 1);
  return 0;
}
