#include <bits/stdc++.h>
using namespace std;
char seq[200005];
int ar[200005], nxt[200005], prv[200005];
bool vis[200005];
set<pair<int, int> > s;
vector<pair<int, int> > ans;
int main() {
  int n, i, x, px, ny;
  scanf("%d", &n);
  scanf("%s", seq);
  for (i = 0; i < n; i++) scanf("%d", &ar[i]);
  for (i = 0; i + 1 < n; i++) {
    if ((seq[i] == 'B' && seq[i + 1] == 'G') ||
        (seq[i] == 'G' && seq[i + 1] == 'B')) {
      s.insert(make_pair(fabs(ar[i] - ar[i + 1]), i));
    }
    nxt[i] = i + 1;
    prv[i] = i - 1;
  }
  nxt[n - 1] = -1;
  while (s.size()) {
    x = s.begin()->second;
    s.erase(s.begin());
    ans.push_back(make_pair(x, nxt[x]));
    px = prv[x];
    ny = nxt[nxt[x]];
    if (px != -1) {
      nxt[px] = ny;
      s.erase(make_pair(fabs(ar[px] - ar[x]), px));
    }
    if (ny != -1) {
      prv[ny] = px;
      s.erase(make_pair(fabs(ar[nxt[x]] - ar[ny]), nxt[x]));
    }
    if (px == -1 || ny == -1) continue;
    if ((seq[px] == 'B' && seq[ny] == 'G') ||
        (seq[px] == 'G' && seq[ny] == 'B')) {
      s.insert(make_pair(fabs(ar[px] - ar[ny]), px));
    }
  }
  printf("%d\n", ans.size());
  for (i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
  return 0;
}
