#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, d;
  bool operator<(const node &t) const {
    return (d > t.d) || ((d == t.d) && (x > t.x));
  }
} temp;
int n, r[200005], x[200005], y[200005], X, Y, out, a[100005][2];
char s[200005];
bool b[200005];
priority_queue<node> q;
int main() {
  scanf("%d%s", &n, s);
  for (int i = 0; i < n; i++) {
    scanf("%d", &r[i]);
    x[i] = i - 1;
    y[i] = i + 1;
    b[i] = true;
  }
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      temp.x = i - 1;
      temp.y = i;
      temp.d = abs(r[i] - r[i - 1]);
      q.push(temp);
    }
  }
  out = 0;
  while (!q.empty()) {
    temp = q.top();
    X = temp.x;
    Y = temp.y;
    q.pop();
    if ((b[X]) && (b[Y])) {
      b[X] = false;
      b[Y] = false;
      a[out][0] = X;
      a[out][1] = Y;
      out++;
      if (x[X] >= 0) {
        y[x[X]] = y[Y];
      }
      if (y[Y] < n) {
        x[y[Y]] = x[X];
      }
      if ((x[X] >= 0) && (y[Y] < n) && (s[x[X]] != s[y[Y]])) {
        temp.x = x[X];
        temp.y = y[Y];
        temp.d = abs(r[x[X]] - r[y[Y]]);
        q.push(temp);
      }
    }
  }
  printf("%d\n", out);
  for (int i = 0; i < out; i++) {
    printf("%d %d\n", a[i][0] + 1, a[i][1] + 1);
  }
  return 0;
}
