#include <bits/stdc++.h>
using namespace std;
int a[200010];
char BG[200010];
int main() {
  memset(a, 0, sizeof(a));
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      pq;
  set<int> num;
  int n = 0;
  scanf("%d", &n);
  scanf("%s", BG + 1);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    num.insert(i);
  }
  for (int i = 1; i + 1 <= n; ++i) {
    if (BG[i] != BG[i + 1]) {
      int tmp = abs(a[i] - a[i + 1]);
      pq.push(make_pair(tmp, make_pair(i, i + 1)));
    }
  }
  vector<pair<int, int>> res;
  while (!pq.empty()) {
    auto cur = pq.top();
    pq.pop();
    int l = cur.second.first, r = cur.second.second;
    if (!num.count(l) || !num.count(r)) {
      continue;
    }
    res.push_back(make_pair(l, r));
    auto le = num.find(l);
    if (le != num.begin()) {
      --le;
      auto ri = num.find(r);
      ++ri;
      if (ri != num.end() && BG[*le] != BG[*ri]) {
        pq.push(make_pair(abs(a[*le] - a[*ri]), make_pair(*le, *ri)));
      }
    }
    num.erase(l);
    num.erase(r);
  }
  printf("%d\n", (int)res.size());
  for (int i = 0; i < res.size(); ++i) {
    printf("%d %d\n", res[i].first, res[i].second);
  }
  return 0;
}
