#include <bits/stdc++.h>
using namespace std;
struct man {
  int l, r;
};
bool U[200010];
man sosed[200010];
int skill[200010];
char sex[200010];
int main() {
  int n;
  cin >> n;
  priority_queue<pair<int, int> > Q;
  for (int i = 0; i < n; ++i) {
    cin >> sex[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> skill[i];
  }
  for (int i = 0; i < n; ++i) {
    if (i > 0)
      if (sex[i] != sex[i - 1])
        Q.push(make_pair(-abs(skill[i] - skill[i - 1]), -(i - 1)));
    sosed[i].l = i - 1;
    sosed[i].r = i + 1;
  }
  vector<pair<int, int> > res;
  pair<int, int> v;
  int f, s;
  while (!Q.empty()) {
    v = Q.top();
    Q.pop();
    f = -v.second;
    s = sosed[f].r;
    if (f >= 0 && s < n && !U[f] && !U[s])
      if (abs(skill[f] - skill[s]) == -v.first && sex[f] != sex[s]) {
        res.push_back(make_pair(f + 1, s + 1));
        U[f] = true;
        U[s] = true;
        sosed[sosed[f].l].r = sosed[s].r;
        sosed[sosed[s].r].l = sosed[f].l;
        if (sosed[f].l >= 0 && sosed[s].r < n &&
            sex[sosed[f].l] != sex[sosed[s].r])
          Q.push(make_pair(-abs(skill[sosed[f].l] - skill[sosed[s].r]),
                           -(sosed[f].l)));
      }
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); ++i)
    cout << res[i].first << " " << res[i].second << endl;
  return 0;
}
