#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1000 * 100 + 21;
struct couple {
  int i, j;
  couple(){};
  couple(int a, int b) {
    i = min(a, b);
    j = max(a, b);
  }
};
int n;
int a[maxn];
int r[maxn];
int l[maxn];
int b[maxn];
vector<pair<int, int> > ans;
set<couple> s;
bool operator<(const couple &c1, const couple &c2) {
  int a1 = abs(a[c1.j] - a[c1.i]);
  int a2 = abs(a[c2.j] - a[c2.i]);
  if (a1 != a2) return a1 < a2;
  return c1.i < c2.i;
}
void input() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'B') b[i] = 1;
  }
  for (int i = 0; i < n; i++) cin >> a[i];
}
int main() {
  input();
  l[0] = -1;
  r[n - 1] = -1;
  for (int i = 0; i < n - 1; i++) {
    r[i] = i + 1;
    l[i + 1] = i;
    if (b[i] != b[i + 1]) {
      s.insert(couple(i, i + 1));
    }
  }
  while (!s.empty()) {
    int i = s.begin()->i;
    int j = s.begin()->j;
    s.erase(s.begin());
    s.erase(couple(l[i], i));
    s.erase(couple(j, r[j]));
    ans.push_back(make_pair(i, j));
    r[l[i]] = r[j];
    l[r[j]] = l[i];
    if (l[i] != -1 && r[j] != -1 && b[l[i]] != b[r[j]])
      s.insert(couple(l[i], r[j]));
  }
  cout << int(ans.size()) << endl;
  for (int i = 0; i < int(ans.size()); i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
}
