#include <bits/stdc++.h>
using namespace std;
class Skill {
 public:
  int s, l, r;
  Skill(int _s, int _l, int _r) : s(_s), l(_l), r(_r) {}
  friend inline bool operator<(const Skill& o1, const Skill& o2) {
    if (o1.s != o2.s) return !(o1.s < o2.s);
    return !(o1.l < o2.l);
  }
};
int main() {
  int n, i, j, i2, j2;
  vector<char> bg;
  vector<int> a;
  set<int> lst;
  priority_queue<Skill> q;
  vector<pair<int, int> > ans;
  scanf("%d", &n);
  bg.assign(n, 0);
  scanf("%c", &bg[0]);
  for_each(bg.begin(), bg.end(), [](char& o) { scanf("%c", &o); });
  a.assign(n, 0);
  for_each(a.begin(), a.end(), [](int& o) { scanf("%d", &o); });
  lst.insert(0);
  for (int i = 1; i != n; ++i) {
    if (bg[i] != bg[i - 1]) q.push(Skill(abs(a[i - 1] - a[i]), i - 1, i));
    lst.insert(i);
  }
  while (!q.empty()) {
    i = q.top().l;
    j = q.top().r;
    q.pop();
    if (lst.find(i) == lst.end() || lst.find(j) == lst.end()) continue;
    ans.push_back(make_pair(i, j));
    if (lst.find(i) != lst.begin() && lst.find(j) != --lst.end()) {
      i2 = *(--lst.find(i));
      j2 = *(++lst.find(j));
      if (bg[i2] != bg[j2]) q.push(Skill(abs(a[i2] - a[j2]), i2, j2));
    }
    lst.erase(i);
    lst.erase(j);
  }
  printf("%d\n", (int)ans.size());
  for_each(ans.begin(), ans.end(), [](const pair<int, int>& o) {
    printf("%d %d\n", o.first + 1, o.second + 1);
  });
  return 0;
}
