#include <bits/stdc++.h>
using namespace std;
int n, ka, ans[210010][7], a[210010], d, l[210010], r[210010];
pair<int, int> o;
set<pair<int, pair<int, int> > > s;
char c[210010];
set<pair<int, pair<int, int> > >::iterator it;
pair<int, pair<int, int> > k;
int abs(int a) {
  if (a >= 0) return a;
  return -a;
}
int main() {
  scanf("%d", &n);
  char ch;
  scanf("%c", &ch);
  ka = 0;
  for (int i = 0; i < n; i++) scanf("%c", &c[i]);
  c[n] = 'A';
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) l[i] = i - 1;
  for (int i = 0; i < n - 1; i++) r[i] = i + 1;
  l[0] = n;
  r[n - 1] = n;
  for (int i = 0; i < n - 1; i++) {
    if (c[i] == 'B' && c[i + 1] == 'G') {
      int x = 0;
      x = abs(a[i] - a[i + 1]);
      s.insert(make_pair(x, make_pair(i, i + 1)));
    }
    if (c[i] == 'G' && c[i + 1] == 'B') {
      int x = 0;
      x = abs(a[i] - a[i + 1]);
      s.insert(make_pair(x, make_pair(i, i + 1)));
    }
  }
  while (s.size() > 0) {
    k = *(s.begin());
    ka++;
    ans[ka][1] = k.second.first;
    ans[ka][2] = k.second.second;
    s.erase(s.begin());
    l[r[k.second.second]] = l[k.second.first];
    l[k.second.second] = l[k.second.first];
    r[l[k.second.first]] = r[k.second.second];
    r[k.second.first] = r[k.second.second];
    o.first = l[k.second.first];
    o.second = k.second.first;
    d = abs(a[o.first] - a[o.second]);
    it = s.find(make_pair(d, o));
    if (it != s.end()) s.erase(it);
    o.first = k.second.second;
    o.second = r[k.second.second];
    d = abs(a[o.first] - a[o.second]);
    it = s.find(make_pair(d, o));
    if (it != s.end()) s.erase(it);
    o.first = l[k.second.first];
    o.second = r[k.second.second];
    d = abs(a[o.first] - a[o.second]);
    if ((c[o.first] == 'G' && c[o.second] == 'B') ||
        (c[o.first] == 'B' && c[o.second] == 'G'))
      s.insert(make_pair(d, o));
  }
  printf("%d\n", ka);
  for (int i = 1; i <= ka; i++) printf("%d %d\n", ans[i][1] + 1, ans[i][2] + 1);
  return 0;
}
