#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const double PI = 3.141592653589793;
const int N = 200005;
int n, pl[N], um[N], k1, k2, lewy[N], prawy[N], i;
pair<int, pair<int, int> > p;
set<pair<int, pair<int, int> > > zbior;
vector<pair<int, int> > wek;
char t[N];
bool used[N];
int main() {
  scanf("%d %s", &n, &t);
  for (i = 0; i < n; i++) scanf("%d", &um[i]);
  for (i = 0; i < n; i++) {
    lewy[i] = i - 1;
    prawy[i] = i + 1;
    pl[i] = (t[i] == 'B');
    used[i] = false;
  }
  zbior.clear();
  wek.resize(0);
  for (i = 0; i < n - 1; i++)
    if (pl[i] + pl[i + 1] == 1)
      zbior.insert(pair<int, pair<int, int> >(abs(um[i] - um[i + 1]),
                                              pair<int, int>(i, i + 1)));
  while (!zbior.empty()) {
    p = *zbior.begin();
    k1 = p.second.first;
    k2 = p.second.second;
    zbior.erase(p);
    if (!used[k1] && !used[k2]) {
      wek.push_back(pair<int, int>(k1, k2));
      if (lewy[k1] != -1) prawy[lewy[k1]] = prawy[k2];
      if (prawy[k2] != n) lewy[prawy[k2]] = lewy[k1];
      if (lewy[k1] != -1 && prawy[k2] != n && pl[lewy[k1]] + pl[prawy[k2]] == 1)
        zbior.insert(
            pair<int, pair<int, int> >(abs(um[lewy[k1]] - um[prawy[k2]]),
                                       pair<int, int>(lewy[k1], prawy[k2])));
      used[k1] = true;
      used[k2] = true;
    }
  }
  printf("%d\n", wek.size());
  for (i = 0; i < wek.size(); i++)
    printf("%d %d\n", wek[i].first + 1, wek[i].second + 1);
  return 0;
}
