#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 1000 * 100 + 10;
string str;
set<pair<int, pair<int, int> > > s;
struct node {
  int pre, next, key;
  bool g, val;
};
vector<pair<int, int> > ans;
node a[MAXN];
int n;
int main() {
  cin >> n >> str;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].key);
    a[i].pre = (i - 1);
    a[i].next = (i + 1);
    a[i].g = (str[i] == 'G') ? true : false;
    a[i].val = true;
  }
  for (int i = 0; i < n - 1; i++)
    if (str[i] != str[i + 1])
      s.insert(make_pair(abs(a[i].key - a[i + 1].key), make_pair(i, i + 1)));
  while (!s.empty()) {
    if (a[(s.begin()->second.first)].val && a[(s.begin()->second.second)].val) {
      ans.push_back(s.begin()->second);
      int u, v;
      u = s.begin()->second.first;
      v = s.begin()->second.second;
      a[a[u].pre].next = a[v].next;
      a[a[v].next].pre = a[u].pre;
      a[u].val = false;
      a[v].val = false;
      s.erase(s.begin());
      if (a[u].pre != -1 && a[v].next != n) {
        if (a[a[u].pre].g != a[a[v].next].g) {
          int k = abs(a[a[u].pre].key - a[a[v].next].key);
          s.insert(make_pair(k, make_pair(min(a[u].pre, a[v].next),
                                          max(a[u].pre, a[v].next))));
        }
      }
    } else
      s.erase(s.begin());
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
  return 0;
}
