#include <bits/stdc++.h>
using namespace std;
struct node {
  int ll;
  int y;
  int d;
  friend bool operator<(const node p, const node q) {
    if (p.d == q.d)
      return p.y > q.y;
    else
      return p.d > q.d;
  }
} t;
int l[200010];
int r[200010];
int b[200010];
int g[2];
int skill[200010];
int main() {
  char cc;
  int n;
  while (scanf("%d", &n) != EOF) {
    getchar();
    memset(g, 0, sizeof(g));
    memset(b, -1, sizeof(b));
    memset(l, -1, sizeof(l));
    memset(r, -1, sizeof(r));
    memset(skill, 0, sizeof(skill));
    for (int i = 0; i < n; i++) {
      scanf("%c", &cc);
      if (cc == 'B') {
        b[i] = 0;
        g[0]++;
      } else {
        b[i] = 1;
        g[1]++;
      }
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &skill[i]);
      l[i] = i - 1;
      r[i] = i + 1;
    }
    priority_queue<node> qq;
    for (int i = 1; i < n; i++) {
      if (b[i] != b[i - 1]) {
        t.d = abs(skill[i] - skill[i - 1]);
        t.y = i;
        t.ll = i - 1;
        qq.push(t);
      }
    }
    int num = min(g[0], g[1]);
    printf("%d\n", num);
    while (num--) {
      while (!qq.empty()) {
        node cur = qq.top();
        qq.pop();
        if ((r[cur.ll] != -1) && (r[cur.y] != -1)) {
          printf("%d %d", cur.ll + 1, cur.y + 1);
          if ((l[cur.ll] != -1) && r[cur.y] < n && r[cur.y] > -1 &&
              (b[l[cur.ll]] + b[r[cur.y]] == 1)) {
            t.ll = l[cur.ll];
            t.y = r[cur.y];
            t.d = abs(skill[l[cur.ll]] - skill[r[cur.y]]);
            qq.push(t);
          }
          r[l[cur.ll]] = r[cur.y];
          l[r[cur.y]] = l[cur.ll];
          r[cur.ll] = -1;
          r[cur.y] = -1;
          printf("\n");
        }
      }
    }
  }
  return 0;
}
