#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4786)
struct node {
  int d, x, y;
  node() {}
  node(int a, int b, int c) {
    x = a;
    y = b;
    d = c;
  }
  bool operator<(const node &a) const {
    return d > a.d || (d == a.d && x > a.x) ||
           (d == a.d && x == a.x && y > a.y);
  }
};
bool vi[200009];
int a[200009], l[200009], r[200009], n;
priority_queue<node> q;
string s;
vector<pair<int, int> > res;
int main() {
  int i;
  node u;
  cin >> n >> s;
  s = "a" + s;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    l[i] = i - 1;
    r[i] = i + 1;
    if (i > 1 && s[i] != s[i - 1]) {
      q.push(node(
          i - 1, i,
          ((a[i] - a[i - 1]) < 0 ? (-(a[i] - a[i - 1])) : (a[i] - a[i - 1]))));
    }
  }
  while (!q.empty()) {
    u = q.top();
    q.pop();
    if (vi[u.x] || vi[u.y]) continue;
    res.push_back(pair<int, int>(u.x, u.y));
    vi[u.x] = vi[u.y] = 1;
    if (l[u.x] > 0 && r[u.y] <= n && s[l[u.x]] != s[r[u.y]])
      q.push(node(l[u.x], r[u.y],
                  ((a[l[u.x]] - a[r[u.y]]) < 0 ? (-(a[l[u.x]] - a[r[u.y]]))
                                               : (a[l[u.x]] - a[r[u.y]]))));
    r[l[u.x]] = r[u.y];
    l[r[u.y]] = l[u.x];
  }
  cout << res.size() << endl;
  for (i = 0; i < res.size(); i++) {
    cout << res[i].first << " " << res[i].second << endl;
  }
  return 0;
}
