#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
char gender[200005];
int prevv[200005], nextt[200005], skill[200005];
priority_queue<pair<int, int> > q;
vector<pair<int, int> > couple;
bool danced[200005];
int main() {
  int i, n, nw, pr, nx;
  pair<int, int> top;
  scanf("%d", &n);
  scanf("%s", gender);
  for (i = 0; i < n; i++) scanf("%d", &skill[i]);
  for (i = 0; i < n - 1; i++) {
    prevv[i] = i - 1;
    nextt[i] = i + 1;
    danced[i] = false;
    if (gender[i] != gender[i + 1])
      q.push(make_pair((-1) * abs(skill[i] - skill[i + 1]), (-1) * i));
  }
  prevv[i] = i - 1;
  nextt[i] = i + 1;
  danced[i] = false;
  while (!q.empty()) {
    top = q.top();
    q.pop();
    nw = top.second * (-1);
    pr = prevv[nw];
    nx = nextt[nw];
    if (nx == n || danced[nw] || danced[nx]) continue;
    if (abs(skill[nw] - skill[nx]) != (-1) * top.first) continue;
    couple.push_back(make_pair(min(nw, nx), max(nw, nx)));
    danced[nw] = danced[nx] = true;
    if (nextt[nx] != n) prevv[nextt[nx]] = pr;
    if (pr != -1) nextt[pr] = nextt[nx];
    nx = nextt[nx];
    if (pr != -1 && nx != n && gender[pr] != gender[nx])
      q.push(make_pair((-1) * abs(skill[nx] - skill[pr]), (-1) * pr));
  }
  printf("%d\n", (int)couple.size());
  for (i = 0; i < couple.size(); i++)
    printf("%d %d\n", couple[i].first + 1, couple[i].second + 1);
  return 0;
}
