#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 200 + 10;
int a[MAXN];
bool boy[MAXN];
vector<pair<int, int> > ans;
struct comp {
  const bool operator()(const pair<int, int>& x,
                        const pair<int, int>& y) const {
    if (abs(a[x.first] - a[x.second]) == abs(a[y.first] - a[y.second]))
      return x.first < y.first;
    return abs(a[x.first] - a[x.second]) < abs(a[y.first] - a[y.second]);
  }
};
set<pair<int, bool> > people;
multiset<pair<int, int>, comp> mates;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char tmp;
    cin >> tmp;
    boy[i] = tmp == 'B';
    people.insert(pair<int, bool>(i, boy[i]));
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0 && boy[i] != boy[i - 1]) mates.insert(pair<int, int>(i - 1, i));
  }
  while (!mates.empty()) {
    pair<int, int> cur = *mates.begin();
    mates.erase(mates.begin());
    ans.push_back(cur);
    set<pair<int, bool> >::iterator it =
        people.find(pair<int, bool>(cur.first, boy[cur.first]));
    if (it != people.begin()) {
      it--;
      pair<int, bool> x1 = *it;
      if (x1.second != boy[cur.first])
        mates.erase(pair<int, int>(x1.first, cur.first));
      it++;
    }
    it++;
    it++;
    if (it != people.end()) {
      pair<int, bool> x2 = *it;
      if (x2.second != boy[cur.second])
        mates.erase(pair<int, int>(cur.second, x2.first));
    }
    it--;
    it--;
    if (it != people.begin()) {
      it--;
      pair<int, bool> x1 = *it;
      it++;
      it++;
      it++;
      if (it != people.end()) {
        pair<int, bool> x2 = *it;
        if (x2.second != x1.second)
          mates.insert(pair<int, int>(x1.first, x2.first));
        if (x2.second != boy[cur.second])
          mates.erase(pair<int, int>(cur.second, x2.first));
      }
    }
    people.erase(pair<int, bool>(cur.first, boy[cur.first]));
    people.erase(pair<int, bool>(cur.second, boy[cur.second]));
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  return 0;
}
