#include <bits/stdc++.h>
using namespace std;
bool ch[200001];
struct info {
  long long df, l, r;
};
struct cmp {
  bool operator()(const info& a, const info& b) {
    if (a.df == b.df) return a.l > b.l;
    return a.df > b.df;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  long long int i, j, x, n, cnt = 0, m, y, k, g, flg, lft, rgt;
  priority_queue<info, vector<info>, cmp> pq;
  string in, a;
  in += 'a';
  cin >> n >> a;
  in += a;
  long long sk[n + 1], lp[n + 1], rp[n + 1];
  info d;
  vector<pair<long long, long long> > ans;
  for (i = 1; i <= n; i++) {
    cin >> sk[i];
  }
  if (n == 1) {
    cout << 0;
    return 0;
  }
  if (in[1] != in[2])
    d.df = abs(sk[1] - sk[2]);
  else
    d.df = 1e9;
  d.l = 1;
  d.r = 2;
  pq.push(d);
  lp[1] = -1;
  rp[1] = 2;
  if (n > 2) {
    if (in[n] != in[n - 1])
      d.df = abs(sk[n] - sk[n - 1]);
    else
      d.df = 1e9;
    d.l = n - 1;
    d.r = n;
  }
  lp[n] = n - 1;
  rp[n] = -1;
  for (i = 2; i <= n - 1; i++) {
    if (in[i] != in[i - 1])
      d.df = abs(sk[i] - sk[i - 1]);
    else
      d.df = 1e9;
    d.l = i - 1;
    d.r = i;
    pq.push(d);
    if (in[i] != in[i + 1])
      d.df = abs(sk[i] - sk[i + 1]);
    else
      d.df = 1e9;
    d.l = i;
    d.r = i + 1;
    pq.push(d);
    lp[i] = i - 1;
    rp[i] = i + 1;
  }
  while (!pq.empty()) {
    d = pq.top();
    pq.pop();
    if (ch[d.l] || ch[d.r]) continue;
    if (d.df > 1e8) break;
    lft = lp[d.l];
    rgt = rp[d.r];
    ans.push_back(make_pair(d.l, d.r));
    ch[d.l] = ch[d.r] = 1;
    if (lft != -1 && rgt != -1) {
      if (in[lft] != in[rgt])
        d.df = abs(sk[lft] - sk[rgt]);
      else
        d.df = 1e9;
      d.l = lft;
      d.r = rgt;
      pq.push(d);
    }
    if (lft != -1) rp[lft] = rgt;
    if (rgt != -1) lp[rgt] = lft;
  }
  cout << ans.size() << endl;
  if (ans.size() > 0) {
    for (i = 0; i <= ans.size() - 1; i++) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
}
