#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
const long long INF64 = (long long)1E16;
int distsq(int x1, int y1, int x2, int y2) {
  return sqr(x1 - x2) + sqr(y1 - y2);
}
double dist2d(double x1, double y1, double x2, double y2) {
  return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}
long long toInt64(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double LOG(long long N, long long B) { return (log10l(N)) / (log10l(B)); }
string itoa(long long a) {
  if (a == 0) return "0";
  string ret;
  for (long long i = a; i > 0; i = i / 10) ret.push_back((i % 10) + 48);
  reverse(ret.begin(), ret.end());
  return ret;
}
vector<string> token(string a, string b) {
  const char *q = a.c_str();
  while (count(b.begin(), b.end(), *q)) q++;
  vector<string> oot;
  while (*q) {
    const char *e = q;
    while (*e && !count(b.begin(), b.end(), *e)) e++;
    oot.push_back(string(q, e));
    q = e;
    while (count(b.begin(), b.end(), *q)) q++;
  }
  return oot;
}
int isvowel(char s) {
  s = tolower(s);
  if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') return 1;
  return 0;
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
int check(int N, int pos) { return (N & (1 << pos)); }
int toggle(int N, int pos) {
  if (check(N, pos)) return N = reset(N, pos);
  return N = Set(N, pos);
}
void pbit(int N) {
  printf("(");
  for (int i = 10; i >= 0; i--) {
    bool x = check(N, i);
    cout << x;
  }
  puts(")");
}
string s;
int w[200102];
struct node {
  int d;
  int i, j;
  node(int d1, int i1, int j1) {
    d = d1;
    i = i1;
    j = j1;
  }
  bool operator<(const node &p) const {
    if (d == p.d) {
      if (i == p.i) return j < p.j;
      return i < p.i;
    }
    return d < p.d;
  }
};
set<node> ms;
int L[200102], R[200102];
int main() {
  int n;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < n; i++) {
    L[i] = i - 1;
    R[i] = i + 1;
  }
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      int d = abs(w[i] - w[i + 1]);
      ms.insert(node(d, i, i + 1));
    }
  }
  bool taken[200102] = {0};
  vector<pair<int, int> > v;
  while (!ms.empty()) {
    node top = *ms.begin();
    ms.erase(ms.begin());
    if (taken[top.i]) continue;
    if (taken[top.j]) continue;
    taken[top.i] = 1;
    taken[top.j] = 1;
    v.push_back(pair<int, int>(top.i + 1, top.j + 1));
    int i2 = L[top.i];
    int j2 = R[top.j];
    if (i2 >= 0) R[i2] = j2;
    if (j2 < n) L[j2] = i2;
    if (i2 >= 0 and j2 < n and s[i2] != s[j2]) {
      int d = abs(w[i2] - w[j2]);
      ms.insert(node(d, i2, j2));
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < (int)v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
}
