#include <bits/stdc++.h>
using namespace std;
struct Event {
  int d, a, b;
  Event(int _d, int _a, int _b) : d(_d), a(_a), b(_b) {}
  bool operator<(const Event &x) const {
    if (d != x.d) return d > x.d;
    return min(a, b) > min(x.a, x.b);
  }
};
const int MN = 200009;
char T[MN];
int D[MN];
set<int> K;
vector<pair<int, int> > Out;
int main() {
  priority_queue<Event> Q;
  int n;
  scanf("%d", &n);
  scanf("%s", T);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", &D[i]);
    K.insert(i);
  }
  for (int i = (0); i < (n - 1); ++i)
    if (T[i] != T[i + 1]) Q.push(Event(abs(D[i] - D[i + 1]), i, i + 1));
  while (!Q.empty()) {
    Event e = Q.top();
    Q.pop();
    set<int>::iterator at = K.find(e.a), bt = K.find(e.b), att, btt;
    if (at != K.end() && bt != K.end()) {
      Out.push_back(make_pair(min(e.a, e.b), max(e.a, e.b)));
      att = at;
      btt = bt;
      btt++;
      if (at != K.begin() && btt != K.end()) {
        att--;
        if (T[*att] != T[*btt])
          Q.push(Event(abs(D[*att] - D[*btt]), *att, *btt));
      }
      K.erase(at);
      K.erase(bt);
    }
  }
  printf("%d\n", Out.size());
  for (__typeof__((Out).begin()) w = (Out).begin(); w != (Out).end(); ++w)
    printf("%d %d\n", w->first + 1, w->second + 1);
}
