#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct dancerInfo {
  int delta, num, num2;
  dancerInfo(int _delta = 0, int _num = 0, int _num2 = 0) {
    delta = _delta;
    num = _num;
    num2 = _num2;
  }
  bool operator<(const dancerInfo a) const {
    return delta < a.delta || delta == a.delta && num < a.num ||
           delta == a.delta && num == a.num && num2 < a.num2;
  }
};
struct ptrs {
  int lef, rig;
  ptrs(int _lef = 0, int _rig = 0) {
    lef = _lef;
    rig = _rig;
  }
};
ptrs ptr[N];
string s;
set<dancerInfo> dan;
int a[N];
bool use[N];
vector<int> ansf, anss;
bool ok(int i, int j) {
  return s[i] == 'B' && s[j] == 'G' || s[i] == 'G' && s[j] == 'B';
}
int abs(int x) { return (x < 0 ? -x : x); }
int main() {
  int n;
  cin >> n >> s;
  s = 'P' + s;
  use[0] = true;
  a[0] = 1000000000;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    ptr[i - 1].rig = i;
    ptr[i].lef = i - 1;
    if (ok(i - 1, i)) dan.insert(dancerInfo(abs(a[i] - a[i - 1]), i - 1, i));
  }
  int frs, sec;
  while (dan.size()) {
    dancerInfo v = (*dan.begin());
    dan.erase(dan.begin());
    if (use[v.num] || use[v.num2] || ptr[v.num].rig != v.num2 ||
        ptr[v.num2].lef != v.num)
      continue;
    ansf.push_back(v.num);
    anss.push_back(v.num2);
    use[v.num] = use[v.num2] = true;
    frs = ptr[v.num].lef;
    sec = ptr[v.num2].rig;
    ptr[frs].rig = (frs == 0 ? 0 : sec);
    ptr[sec].lef = (sec == 0 ? 0 : frs);
    if (ok(frs, sec)) dan.insert(dancerInfo(abs(a[frs] - a[sec]), frs, sec));
  }
  cout << ansf.size() << endl;
  for (int i = 0; i < ansf.size(); i++)
    cout << ansf[i] << " " << anss[i] << endl;
  return 0;
}
