#include <bits/stdc++.h>
using namespace std;
int n, s[200001];
char g[200001];
set<pair<int, pair<int, int> > > S;
vector<pair<int, int> > ans;
int l[200001], r[200001];
void run() {
  cin >> n >> g;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    l[i] = r[i] = -1;
  }
  S.clear();
  ans.clear();
  for (int i = 0; i < n - 1; i++) {
    if (g[i] != g[i + 1])
      S.insert(make_pair(abs(s[i] - s[i + 1]), make_pair(i, i + 1)));
    r[i] = i + 1;
    l[i + 1] = i;
  }
  while (!S.empty()) {
    int a = (*S.begin()).second.first, b = (*S.begin()).second.second;
    int aa = l[a], bb = r[b];
    S.erase(S.begin());
    ans.push_back(make_pair(a + 1, b + 1));
    if (aa >= 0) {
      S.erase(make_pair(abs(s[a] - s[aa]), make_pair(aa, a)));
      r[aa] = bb;
    }
    if (bb >= 0) {
      S.erase(make_pair(abs(s[b] - s[bb]), make_pair(b, bb)));
      l[bb] = aa;
    }
    if (aa >= 0 && bb >= 0 && g[aa] != g[bb])
      S.insert(make_pair(abs(s[aa] - s[bb]), make_pair(aa, bb)));
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
int main() {
  run();
  return 0;
}
