#include <bits/stdc++.h>
using namespace std;
set<pair<int, pair<int, int> > > dist;
set<pair<int, int> > s;
char c[222222];
int a[222222];
int n;
int main() {
  scanf("%d", &n);
  scanf("%s", &c);
  int c1 = 0, c2 = 0;
  for (int(i) = 0; (i) < (n); ++(i)) {
    scanf("%d", &a[i]);
    if (c[i] == 'B') {
      s.insert(make_pair(i, 0));
      ++c1;
    } else {
      s.insert(make_pair(i, 1));
      ++c2;
    }
  }
  s.insert(make_pair(-1, -1));
  s.insert(make_pair(n, n));
  for (int(i) = 0; (i) < (n - 1); ++(i))
    if (c[i] != c[i + 1])
      dist.insert(make_pair(abs(a[i] - a[i + 1]), make_pair(i, i + 1)));
  printf("%d\n", min(c1, c2));
  while ((int)dist.size()) {
    pair<int, pair<int, int> > p = *dist.begin();
    dist.erase(dist.begin());
    set<pair<int, int> >::iterator i =
        s.lower_bound(make_pair(p.second.first, -1));
    if (i->first != p.second.first) continue;
    i = s.lower_bound(make_pair(p.second.second, -1));
    if (i->first != p.second.second) continue;
    printf("%d %d\n", p.second.first + 1, p.second.second + 1);
    s.erase(s.lower_bound(make_pair(p.second.first, -1)));
    s.erase(s.lower_bound(make_pair(p.second.second, -1)));
    set<pair<int, int> >::iterator it =
        s.lower_bound(make_pair(p.second.first, -1));
    --it;
    if (it != s.begin()) {
      set<pair<int, int> >::iterator it2 =
          s.lower_bound(make_pair(p.second.first, -1));
      if (it2->first != n) {
        if (it2->second != it->second) {
          dist.insert(make_pair(abs(a[it->first] - a[it2->first]),
                                make_pair(it->first, it2->first)));
        }
      }
    }
  }
  return 0;
}
