#include <bits/stdc++.h>
using namespace std;
int le[250000];
int ri[250000];
int arr[250000];
bool mark[250000];
priority_queue<pair<int, pair<int, int> > > pq;
vector<pair<int, int> > v;
int checkle(int x) {
  if (le[x] == x) return x;
  return le[x] = checkle(le[x]);
}
int checkri(int x) {
  if (ri[x] == x) return x;
  return ri[x] = checkri(ri[x]);
}
const int INF = 1e9;
string s;
bool diff(int x, int y) { return s[x - 1] != s[y - 1]; }
int main() {
  int n;
  scanf("%d", &n);
  cin >> s;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    le[i] = ri[i] = i;
    if (s[i - 1] == 'G') {
      if (i != 1) {
        if (s[i - 2] == 'B')
          pq.push(
              make_pair(-abs(arr[i] - arr[i - 1]), make_pair(-i, -(i - 1))));
      }
      if (i != n && s[i] == 'B') {
        if (s[i] == 'B')
          pq.push(
              make_pair(-abs(arr[i] - arr[i + 1]), make_pair(-i, -(i + 1))));
      }
    }
  }
  le[n + 1] = ri[n + 1] = n + 1;
  memset(mark, false, sizeof(mark));
  while (!pq.empty()) {
    int val = -pq.top().first;
    int gi = -pq.top().second.first;
    int boy = -pq.top().second.second;
    pq.pop();
    if (gi == 0 || boy == n + 1 || diff(gi, boy) == false || mark[gi] == true ||
        mark[boy] == true) {
      continue;
    }
    v.push_back(make_pair(min(gi, boy), max(gi, boy)));
    le[gi] = checkle(gi - 1);
    ri[gi] = checkri(gi + 1);
    le[boy] = checkle(boy - 1);
    ri[boy] = checkri(boy + 1);
    if (diff(checkle(le[gi]), checkri(ri[boy])) == true) {
      int l = checkle(le[gi]);
      int r = checkri(ri[boy]);
      int i = l;
      if (s[l - 1] == 'G' && r != n + 1) {
        pq.push(make_pair(-abs(arr[l] - arr[r]), make_pair(-l, -r)));
      }
      if (s[r - 1] == 'G' && l != 0) {
        pq.push(make_pair(-abs(arr[l] - arr[r]), make_pair(-r, -l)));
      }
    }
    mark[boy] = true;
    mark[gi] = true;
  }
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
}
