#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic warning "-Wall"
int main() {
  ios::sync_with_stdio(false);
  int n;
  string sex;
  cin >> n;
  cin >> sex;
  vector<int> skill(n);
  for (typeof(n) i = (0); i < (n); i++) cin >> skill[i];
  vector<int> prev(n);
  prev[0] = -1;
  for (typeof(n) i = (1); i < (n); i++) prev[i] = i - 1;
  vector<int> next(n);
  next[n - 1] = -1;
  for (typeof(n - 1) i = (0); i < (n - 1); i++) next[i] = i + 1;
  set<pair<int, pair<int, int> > > q;
  for (typeof(n - 1) ia = (0); ia < (n - 1); ia++) {
    int ib = ia + 1;
    if (sex[ia] == sex[ib]) continue;
    q.insert(make_pair(abs(skill[ia] - skill[ib]), make_pair(ia, ib)));
  }
  vector<bool> used(n);
  vector<pair<int, int> > couples;
  while (not q.empty()) {
    pair<int, int> c = q.begin()->second;
    q.erase(q.begin());
    if (used[c.first] or used[c.second]) continue;
    couples.push_back(c);
    used[c.first] = true;
    used[c.second] = true;
    if (prev[c.first] != -1) next[prev[c.first]] = next[c.second];
    if (next[c.second] != -1) prev[next[c.second]] = prev[c.first];
    if (prev[c.first] != -1 and next[c.second] != -1) {
      int ia = prev[c.first];
      int ib = next[c.second];
      if (sex[ia] != sex[ib]) {
        q.insert(make_pair(abs(skill[ia] - skill[ib]), make_pair(ia, ib)));
      }
    }
  }
  cout << couples.size() << endl;
  for (typeof((couples).begin()) c = (couples).begin(); c != (couples).end();
       c++) {
    cout << (c->first + 1) << " " << (c->second + 1) << endl;
  }
}
