#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000000")
using namespace std;
const double EPS = 1e-9;
const int INF = (int)(2e9 + 0.5);
const int MAXN = 201000;
struct DoublyLinkedList {
  int next[MAXN];
  int prev[MAXN];
  void insert(int x, int pos) {
    prev[x] = pos;
    next[x] = next[pos];
    prev[next[x]] = x;
    next[prev[x]] = x;
  }
  void remove(int x) {
    next[prev[x]] = next[x];
    prev[next[x]] = prev[x];
  }
};
struct element {
  int value, pos1, pos2;
  element(){};
  element(const int& value, const int& pos1, const int& pos2)
      : value(value), pos1(pos1), pos2(pos2){};
  bool operator<(const element& e) const {
    if (value == e.value) return pos1 > e.pos1;
    return value > e.value;
  }
};
int n, skill[MAXN];
char ch, seq[MAXN], killed[MAXN];
priority_queue<element> q;
vector<pair<int, int> > ans;
int main() {
  scanf("%d", &n);
  scanf("%c", &ch);
  for (int i = 1; i <= n; scanf("%c", &seq[i]), ++i)
    ;
  for (int i = 1; i <= n; scanf("%d", &skill[i]), ++i)
    ;
  DoublyLinkedList l;
  for (int i = 1; i <= n; ++i) l.insert(i, i - 1);
  for (int i = 2; i <= n; ++i)
    if ((seq[i] == 'B' && seq[i - 1] == 'G') ||
        (seq[i] == 'G' && seq[i - 1] == 'B'))
      q.push(element(abs(skill[i - 1] - skill[i]), i - 1, i));
  while (!q.empty()) {
    element e = q.top();
    q.pop();
    if (killed[e.pos1] || killed[e.pos2]) continue;
    ans.push_back(make_pair(e.pos1, e.pos2));
    killed[e.pos1] = true;
    killed[e.pos2] = true;
    int newPos1 = l.prev[e.pos1];
    int newPos2 = l.next[e.pos2];
    l.remove(e.pos1);
    l.remove(e.pos2);
    if (!newPos1 || !newPos2) continue;
    if ((seq[newPos1] == 'G' && seq[newPos2] == 'B') ||
        (seq[newPos1] == 'B' && seq[newPos2] == 'G'))
      q.push(element(abs(skill[newPos1] - skill[newPos2]), newPos1, newPos2));
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size();
       printf("%d %d\n", ans[i].first, ans[i].second), ++i)
    ;
  return 0;
}
