#include <bits/stdc++.h>
using namespace std;
char s[200011];
int a[200011];
int ans[100011][2];
int ll[200011], rr[200011];
int vis[200011];
int cnt;
struct node {
  int l, r;
  int x;
  friend bool operator<(node a, node b) {
    if (a.x == b.x) return a.l > b.l;
    return a.x > b.x;
  }
};
priority_queue<node> q;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i <= n; i++) {
      ll[i] = i - 1;
      rr[i] = i + 1;
    }
    cnt = 0;
    scanf("%s", s);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n - 1; i++) {
      if (s[i] != s[i + 1]) {
        node t = {i, i + 1, abs(a[i + 1] - a[i])};
        q.push(t);
      }
    }
    while (q.size()) {
      node t = q.top();
      if (vis[t.l] == 1 || vis[t.r] == 1) {
        q.pop();
        continue;
      }
      ans[cnt][0] = t.l + 1;
      ans[cnt++][1] = t.r + 1;
      vis[t.l] = vis[t.r] = 1;
      q.pop();
      int l = ll[t.l], r = rr[t.r];
      ll[r] = l;
      rr[l] = r;
      if (l >= 0 && r <= n - 1 && s[l] != s[r]) {
        node tt = {l, r, abs(a[l] - a[r])};
        q.push(tt);
      }
    }
    printf("%d\n", cnt);
    for (int i = 0; i < cnt; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
  }
  return 0;
}
