#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int MAX = 200005;
int a[MAX], l[MAX], r[MAX];
bool boy[MAX];
set<pair<int, int> > dif;
int val(int p) {
  if (l[p] == -1) {
    if (boy[r[p]] != boy[p]) return r[p];
    return -1;
  }
  if (r[p] == -1) {
    if (boy[l[p]] != boy[p]) return l[p];
    return -1;
  }
  if (boy[l[p]] == boy[p] && boy[p] == boy[r[p]]) return -1;
  if (boy[l[p]] == boy[p] && boy[p] != boy[r[p]]) return r[p];
  if (boy[l[p]] != boy[p] && boy[p] == boy[r[p]]) return l[p];
  if (abs(a[l[p]] - a[p]) < abs(a[p] - a[r[p]])) return l[p];
  return r[p];
}
int main() {
  ios::sync_with_stdio(false);
  int n, b = 0, g = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    l[i] = (i == 0 ? -1 : i - 1);
    r[i] = (i == n - 1 ? -1 : i + 1);
    char c;
    cin >> c;
    boy[i] = (c == 'B');
    b += boy[i];
    g += !boy[i];
  }
  cout << min(b, g) << endl;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    if (val(i) != -1) dif.insert(make_pair(abs(a[i] - a[val(i)]), i));
  while (!dif.empty()) {
    int t1 = dif.begin()->second;
    dif.erase(dif.begin());
    int t2 = val(t1);
    dif.erase(make_pair(abs(a[t2] - a[t1]), t2));
    cout << min(t1, t2) + 1 << " " << max(t1, t2) + 1 << endl;
    int upd1, upd2;
    if (t1 < t2) {
      upd1 = l[t1];
      upd2 = r[t2];
    } else {
      upd1 = l[t2];
      upd2 = r[t1];
    }
    if (upd1 != -1 && val(upd1) != -1)
      dif.erase(make_pair(abs(a[upd1] - a[val(upd1)]), upd1));
    if (upd2 != -1 && val(upd2) != -1)
      dif.erase(make_pair(abs(a[upd2] - a[val(upd2)]), upd2));
    r[upd1] = upd2;
    l[upd2] = upd1;
    if (upd1 != -1 && val(upd1) != -1)
      dif.insert(make_pair(abs(a[upd1] - a[val(upd1)]), upd1));
    if (upd2 != -1 && val(upd2) != -1)
      dif.insert(make_pair(abs(a[upd2] - a[val(upd2)]), upd2));
  }
  return 0;
}
