#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-12;
struct parson {
  int id;
  int skill;
  char gender;
  bool operator<(const struct parson &a) const { return id < a.id; }
};
struct parsonPair {
  int diff;
  int id0;
  int id1;
  bool operator<(const struct parsonPair &a) const {
    if (diff != a.diff) return diff > a.diff;
    if (id0 != a.id0) return id0 > a.id0;
    return id1 > a.id1;
  }
};
int main(void) {
  set<parson> ps;
  priority_queue<parsonPair> Q;
  int n;
  cin >> n;
  string gender;
  cin >> gender;
  vector<int> skill(n);
  for (int i = 0; i < (n); ++i) cin >> skill[i];
  parson lastp;
  lastp.id = -1;
  for (int i = 0; i < (n); ++i) {
    parson p;
    p.id = i;
    p.skill = skill[i];
    p.gender = gender[i];
    ps.insert(p);
    if (lastp.id != -1 && lastp.gender != p.gender) {
      parsonPair pp;
      pp.diff = abs(lastp.skill - p.skill);
      pp.id0 = lastp.id;
      pp.id1 = p.id;
      Q.push(pp);
    }
    lastp = p;
  }
  vector<bool> used(n, false);
  vector<pair<int, int> > ans;
  while (!Q.empty()) {
    int id0 = Q.top().id0;
    int id1 = Q.top().id1;
    assert(id0 < id1);
    Q.pop();
    if (used[id0] || used[id1]) continue;
    ans.push_back(make_pair<int, int>(id0 + 1, id1 + 1));
    parson tp0;
    tp0.id = id0;
    parson tp1;
    tp1.id = id1;
    ps.erase(ps.find(tp0));
    ps.erase(ps.find(tp1));
    used[id0] = used[id1] = true;
    if (ps.size() >= 2) {
      set<parson>::iterator it0 = ps.lower_bound(tp0);
      if (it0 == ps.end() || it0 == ps.begin()) continue;
      set<parson>::iterator it1 = it0;
      --it0;
      if (it0->gender != it1->gender) {
        parsonPair pp;
        pp.diff = abs(it0->skill - it1->skill);
        pp.id0 = it0->id;
        pp.id1 = it1->id;
        Q.push(pp);
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < (int)(ans.size()); ++i)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
