#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int pre[maxn], net[maxn], val[maxn];
char str[maxn];
struct Node {
  int l, r, val;
  Node(int l = 0, int r = 0, int val = 0) : l(l), r(r), val(val) {}
  bool operator<(const Node &rhs) const {
    return val > rhs.val || (val == rhs.val && l > rhs.l);
  }
} node[maxn];
priority_queue<Node> ss;
int fabss(int x) { return x < 0 ? -x : x; }
vector<Node> ans;
bool vis[maxn];
bool judge(int l, int r, int n) {
  if (l >= 1 && r <= n && !vis[l] && !vis[r]) return true;
  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  ans.clear();
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) pre[i] = i - 1, net[i] = i + 1;
  for (int i = 1; i < n; i++)
    if (str[i] != str[i + 1])
      ss.push(Node(i, i + 1, fabss(val[i + 1] - val[i])));
  while (!ss.empty()) {
    Node tmp = ss.top();
    ss.pop();
    int l = tmp.l, r = tmp.r;
    if (!judge(l, r, n)) continue;
    vis[l] = 1, vis[r] = 1;
    ans.push_back(Node(l, r, 0));
    int pl = pre[l], nr = net[r];
    net[pl] = nr, pre[nr] = pl;
    if (!judge(pl, nr, n)) continue;
    if (str[pl] != str[nr]) ss.push(Node(pl, nr, fabss(val[pl] - val[nr])));
  }
  int tot = ans.size();
  printf("%d\n", tot);
  for (int i = 0; i < tot; i++) printf("%d %d\n", ans[i].l, ans[i].r);
  return 0;
}
