#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];
char s[MAXN];
int l[MAXN], r[MAXN];
vector<pair<int, int> > v;
bool vis[MAXN];
int main() {
  int m, n, i, j, k;
  scanf("%d", &m);
  for (i = 1; i <= m; i++) l[i] = i - 1, r[i] = i + 1, vis[i] = 1;
  scanf("%s", s + 1);
  for (i = 1; i <= m; i++) scanf("%d", &a[i]);
  set<pair<int, pair<int, int> > > ss;
  set<pair<int, pair<int, int> > >::iterator it;
  for (i = 2; i <= m; i++) {
    if (s[i] != s[i - 1]) {
      ss.insert({abs(a[i] - a[i - 1]), {i - 1, i}});
    }
  }
  while (ss.size()) {
    it = ss.begin();
    pair<int, pair<int, int> > p = *it;
    ss.erase(it);
    int i = p.second.first, j = p.second.second;
    if (vis[i] && vis[j]) {
      v.push_back({i, j});
      vis[i] = vis[j] = false;
      i = l[i];
      j = r[j];
      r[i] = j;
      l[j] = i;
      if (vis[i] && vis[j] && s[i] != s[j]) {
        ss.insert({abs(a[i] - a[j]), {i, j}});
      }
    }
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) printf("%d %d\n", v[i].first, v[i].second);
}
