#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
pair<int, pair<int, int> > ms(int a, int b, int c) {
  return make_pair(a, make_pair(b, c));
}
int x[N];
char s[N + 1];
bool viz[N];
int m = 0;
int l[N], r[N];
int r1[N], r2[N];
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    q;
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n - 1; i++) {
    l[i] = i - 1;
    r[i] = i + 1;
    if (s[i] != s[i + 1]) q.push(ms(abs(x[i + 1] - x[i]), i, i + 1));
  }
  l[n - 1] = n - 2;
  r[n - 1] = n;
  while (!q.empty()) {
    pair<int, pair<int, int> > st = q.top();
    q.pop();
    int i = st.second.first;
    int j = st.second.second;
    if (viz[i] || viz[j]) continue;
    viz[i] = viz[j] = 1;
    r1[m] = i;
    r2[m] = j;
    m++;
    if (l[i] != -1) r[l[i]] = r[j];
    if (r[j] != n) l[r[j]] = l[i];
    if (l[i] != -1 && r[j] != n && s[l[i]] != s[r[j]])
      q.push(ms(abs(x[l[i]] - x[r[j]]), l[i], r[j]));
  }
  printf("%d\n", m);
  for (int i = 0; i < m; i++) printf("%d %d\n", r1[i] + 1, r2[i] + 1);
}
