#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  long long int n, bef[200005], aft[200005], skill[200005];
  priority_queue<
      pair<long long int, pair<long long int, long long int> >,
      vector<pair<long long int, pair<long long int, long long int> > >,
      greater<pair<long long int, pair<long long int, long long int> > > >
      q;
  cin >> n >> str;
  for (long long int i = 0; i < ((long long int)n); i++) bef[i] = i - 1;
  for (long long int i = 0; i < ((long long int)n); i++) aft[i] = i + 1;
  for (long long int i = 0; i < ((long long int)n); i++) cin >> skill[i];
  for (long long int i = 0; i < ((long long int)n - 1); i++)
    if (str[i] != str[i + 1]) {
      q.push(make_pair(abs(skill[i] - skill[i + 1]), make_pair(i, i + 1)));
    }
  vector<pair<long long int, long long int> > ans;
  while (((long long int)q.size())) {
    pair<long long int, pair<long long int, long long int> > p = q.top();
    long long int a = p.second.first;
    long long int b = p.second.second;
    q.pop();
    if (aft[a] == -1 || aft[b] == -1) continue;
    ans.push_back(make_pair(a, b));
    if (bef[a] != -1 && aft[b] != n) {
      if (str[bef[a]] != str[aft[b]]) {
        q.push(make_pair(abs(skill[bef[a]] - skill[aft[b]]),
                         make_pair(bef[a], aft[b])));
      }
    }
    if (bef[a] != -1) {
      aft[bef[a]] = aft[b];
    }
    if (aft[b] != n) {
      bef[aft[b]] = bef[a];
    }
    aft[a] = aft[b] = -1;
  }
  cout << ((long long int)ans.size()) << endl;
  for (long long int i = 0; i < ((long long int)((long long int)ans.size()));
       i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
}
