#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<int, int> > > heap;
vector<pair<int, int> > ans;
int N, a[1000009], n[1000009], p[10000009], u[10000009];
char g[10000009];
int fn(int first) {
  if (u[n[first]]) n[first] = fn(n[first]);
  return n[first];
}
int fp(int first) {
  if (u[p[first]]) p[first] = fp(p[first]);
  return p[first];
}
int main() {
  scanf("%d%s", &N, g);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    p[i] = i - 1;
    n[i] = i + 1;
  }
  for (int i = 1; i < N; i++)
    if (g[i] != g[i - 1])
      heap.push_back(make_pair(
          ((a[i] - a[i - 1]) < 0 ? (a[i] - a[i - 1]) : -(a[i] - a[i - 1])),
          make_pair(-i + 1, -i)));
  make_heap(heap.begin(), heap.end());
  while (heap.size()) {
    int A, B;
    A = -heap.begin()->second.second;
    B = -heap.begin()->second.first;
    pop_heap(heap.begin(), heap.end());
    heap.pop_back();
    if (u[A] || u[B]) continue;
    u[A] = u[B] = 1;
    ans.push_back(make_pair(A, B));
    A = fp(A);
    B = fn(B);
    if (A != -1 && B != N)
      if (g[A] != g[B]) {
        heap.push_back(
            make_pair(((a[A] - a[B]) < 0 ? (a[A] - a[B]) : -(a[A] - a[B])),
                      make_pair(-A, -B)));
        push_heap(heap.begin(), heap.end());
      }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].second + 1, ans[i].first + 1);
  return 0;
}
