#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, t = 0, l, r, a[N], v[N], L[N], R[N];
char s[N];
struct cmp {
  bool operator()(pair<int, int> &r, pair<int, int> &q) const {
    if (abs(a[r.first] - a[r.second]) == abs(a[q.first] - a[q.second]))
      return r.first > q.first;
    return abs(a[r.first] - a[r.second]) > abs(a[q.first] - a[q.second]);
  }
};
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> pq;
int main() {
  cin >> n;
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i), L[i] = i - 1, R[i] = i + 1;
    if (i != 1 && s[i] != s[i - 1]) pq.push({i - 1, i});
    if (s[i] == 'G') t++;
  }
  t = min(t, n - t);
  cout << t << endl;
  while (t) {
    pair<int, int> c = pq.top();
    pq.pop();
    if (v[c.first] || v[c.second]) continue;
    cout << c.first << " " << c.second << endl;
    l = L[c.first], r = R[c.second];
    if (l > 0 && r <= n && s[l] != s[r]) pq.push({l, r});
    L[r] = l, R[l] = r;
    v[c.first] = 1, v[c.second] = 1;
    t--;
  }
}
