#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt,abm,mmx,tune=native")
char sex[200010];
int val[200010];
int l[200010];
int r[200010];
struct node {
  int lpos;
  int rpos;
  int dis;
  bool operator<(const node &r) const {
    return dis > r.dis || dis == r.dis && lpos > r.lpos;
  }
};
int main() {
  int n;
  while (2 == scanf("%u%s", &n, sex + 1)) {
    priority_queue<node> pq;
    node tmp;
    int i;
    int nboy = 0;
    for (i = 1; i <= n; i++) {
      l[i] = i - 1;
      r[i] = i + 1;
      if (sex[i] == 'B') {
        nboy++;
      }
      scanf("%u", &val[i]);
    }
    {
      if (nboy > (n - nboy)) nboy = (n - nboy);
    };
    for (i = 1; i < n; i++) {
      if (sex[i] != sex[i + 1]) {
        tmp.lpos = i;
        tmp.rpos = i + 1;
        tmp.dis = abs(val[i] - val[i + 1]);
        pq.push(tmp);
      }
    }
    printf("%u\n", nboy);
    while (nboy--) {
      do {
        tmp = pq.top();
        pq.pop();
      } while (!sex[tmp.lpos] || !sex[tmp.rpos]);
      printf("%u %u\n", tmp.lpos, tmp.rpos);
      sex[tmp.lpos] = 0;
      sex[tmp.rpos] = 0;
      int lc = l[tmp.lpos];
      int rc = r[tmp.rpos];
      r[lc] = rc;
      l[rc] = lc;
      if ('B' ^ 'G' ^ sex[lc] ^ sex[rc]) {
      } else {
        tmp.lpos = lc;
        tmp.rpos = rc;
        tmp.dis = abs(val[lc] - val[rc]);
        pq.push(tmp);
      }
    }
  }
  return 0;
}
