#include <bits/stdc++.h>
using namespace std;
char tmp[200005];
int n;
inline int abs(int n) {
  if (n > 0) {
    return n;
  } else {
    return -n;
  }
}
struct Node {
  int left, right;
  int skill;
  Node() {}
  Node(int l, int r, int s) {
    left = l;
    right = r;
    skill = s;
  }
  bool operator<(Node o) const {
    if (skill == o.skill) {
      return left > o.left;
    } else {
      return skill > o.skill;
    }
  }
  bool isLegal() {
    if (tmp[left] != 'X' && tmp[right] != 'X') {
      return true;
    } else {
      return false;
    }
  }
} data[200005];
int main() {
  while (scanf("%d", &n) != EOF) {
    scanf("%s", tmp);
    for (int i = 0; i < n; i++) {
      scanf("%d", &data[i].skill);
      data[i].left = i - 1;
      data[i].right = i + 1;
    }
    priority_queue<Node> quu;
    vector<Node> out;
    for (int i = 1; i < n; i++) {
      if (tmp[i] != tmp[i - 1]) {
        quu.push(Node(i - 1, i, abs(data[i].skill - data[i - 1].skill)));
      }
    }
    while (quu.empty() == false) {
      Node p = quu.top();
      quu.pop();
      if (p.isLegal()) {
        out.push_back(Node(p.left, p.right, 0));
        tmp[p.left] = tmp[p.right] = 'X';
        int right = data[data[p.left].left].right = data[p.right].right;
        int left = data[data[p.right].right].left = data[p.left].left;
        if (left != -1 && right != n && tmp[left] != tmp[right]) {
          quu.push(
              Node(left, right, abs(data[left].skill - data[right].skill)));
        }
      }
    }
    printf("%d\n", out.size());
    for (vector<Node>::iterator it = out.begin(); it != out.end(); it++) {
      printf("%d %d\n", it->left + 1, it->right + 1);
    }
  }
  return 0;
}
