#include <bits/stdc++.h>
using namespace std;
struct couple {
  int i1;
  int i2;
  int diff;
  bool operator<(const couple& other) const {
    if (diff > other.diff)
      return 1;
    else if (diff < other.diff)
      return 0;
    else {
      if (i1 > other.i1)
        return 1;
      else
        return 0;
    }
  }
};
int main() {
  priority_queue<couple> pq;
  vector<couple> v;
  int n;
  string s;
  int cnt = 0;
  scanf("%d", &n);
  cin >> s;
  int ara[n];
  int left[n];
  int right[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &ara[i]);
    left[i] = i - 1;
    right[i] = i + 1;
  }
  for (int i = 0; i < s.size() - 1; i++) {
    couple p;
    if (s[i] != s[i + 1]) {
      p.i1 = i;
      p.i2 = i + 1;
      p.diff = abs(ara[i] - ara[i + 1]);
      pq.push(p);
    }
  }
  while (!pq.empty()) {
    couple p = pq.top();
    pq.pop();
    if (ara[p.i1] && ara[p.i2]) {
      cnt++;
      v.push_back(p);
      ara[p.i1] = 0;
      ara[p.i2] = 0;
      couple q;
      q.i1 = left[p.i1];
      q.i2 = right[p.i2];
      right[q.i1] = q.i2;
      left[q.i2] = q.i1;
      if (q.i1 >= 0 && q.i2 <= n - 1) {
        if (ara[q.i1] && ara[q.i2]) {
          if (s[q.i1] != s[q.i2]) {
            q.diff = abs(ara[q.i1] - ara[q.i2]);
            pq.push(q);
          }
        }
      }
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < v.size(); i++) {
    printf("%d %d\n", v[i].i1 + 1, v[i].i2 + 1);
  }
}
