#include <bits/stdc++.h>
struct Node {
  int l, r, s;
};
struct Pair {
  int p1, p2, d;
  Pair(int p1, int p2, int d) : p1(p1), p2(p2), d(d) {}
  bool operator>(const Pair& rhs) const {
    return d > rhs.d || (!(rhs.d > d) && p1 > rhs.p1);
  }
};
int main() {
  int n;
  std::string s;
  std::cin >> n >> s;
  std::vector<Node> v(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> v[i].s;
    v[i].l = i - 1;
    v[i].r = i + 1;
  }
  std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair> > q;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] != s[i + 1]) {
      q.push(Pair(i, i + 1, abs(v[i].s - v[i + 1].s)));
    }
  }
  std::vector<int> used(n);
  std::vector<std::pair<int, int> > res;
  while (!q.empty()) {
    Pair top = q.top();
    q.pop();
    int p1 = top.p1;
    int p2 = top.p2;
    if (used[p1] || used[p2]) {
      continue;
    }
    used[p1] = used[p2] = 1;
    res.push_back(std::make_pair(p1, p2));
    Node& u = v[p1];
    Node& w = v[p2];
    if (0 <= u.l) {
      v[u.l].r = w.r;
    }
    if (w.r < n) {
      v[w.r].l = u.l;
    }
    if (0 <= u.l && w.r < n && s[u.l] != s[w.r]) {
      q.push(Pair(u.l, w.r, abs(v[u.l].s - v[w.r].s)));
    }
  }
  std::cout << res.size() << std::endl;
  for (int i = 0; i < (int)res.size(); ++i) {
    std::cout << res[i].first + 1 << " " << res[i].second + 1 << std::endl;
  }
}
