#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
int n;
struct Node {
  int left;
  int right;
  int diff;
};
int ll[N];
int rr[N];
int level[N];
char sex[N];
bool vis[N];
struct cmp {
  bool operator()(Node x, Node y) {
    if (x.diff != y.diff)
      return x.diff > y.diff;
    else
      return x.left > y.left;
  }
};
priority_queue<Node, vector<Node>, cmp> que;
queue<Node> que1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> sex[i];
    ll[i] = i - 1;
    rr[i] = i + 1;
    if (sex[i] == 'B') ++cnt;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> level[i];
  }
  cnt = min(cnt, n - cnt);
  for (int i = 1; i < n; ++i) {
    if (sex[i] != sex[i + 1]) {
      Node p;
      p.left = i;
      p.right = i + 1;
      p.diff = abs(level[i + 1] - level[i]);
      que.push(p);
    }
  }
  while (cnt--) {
    Node p;
    while (!que.empty()) {
      p = que.top();
      que.pop();
      if (p.left > p.right) swap(p.left, p.right);
      if (!vis[p.left] && !vis[p.right]) {
        vis[p.left] = true;
        vis[p.right] = true;
        que1.push(p);
        break;
      }
    }
    int nl = ll[p.left];
    int nr = rr[p.right];
    rr[nl] = nr;
    ll[nr] = nl;
    if (nl >= 1 && nl <= n && nr >= 1 && nr <= n) {
      if (sex[nl] != sex[nr]) {
        Node q;
        q.left = nl;
        q.right = nr;
        q.diff = abs(level[nl] - level[nr]);
        que.push(q);
      }
    }
  }
  cout << que1.size() << endl;
  while (!que1.empty()) {
    Node p = que1.front();
    que1.pop();
    cout << p.left << " " << p.right << endl;
  }
  return 0;
}
