#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7, inf = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  string str;
  cin >> n >> str;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  ;
  set<pair<int, pair<int, int> > > s;
  set<int> alv;
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    alv.insert(i);
  }
  for (int i = 1; i < n; i++) {
    if (str[i] != str[i - 1]) {
      s.insert({abs(a[i] - a[i - 1]), {i - 1, i}});
    }
  }
  while (not s.empty()) {
    auto x = *s.begin();
    s.erase(s.begin());
    int l, r, nx = -1, pr = -1;
    l = x.second.first;
    if (alv.find(l) == alv.end()) {
      continue;
    }
    r = x.second.second;
    if (alv.find(r) == alv.end()) {
      continue;
    }
    auto it = alv.lower_bound(l);
    if (it != alv.begin()) {
      it = prev(it);
      pr = *it;
    }
    it = alv.upper_bound(r);
    if (it != alv.end()) {
      nx = *it;
    }
    alv.erase(l);
    alv.erase(r);
    ans.push_back({l, r});
    if (nx != -1 and pr != -1) {
      if (str[pr] != str[nx]) {
        s.insert({abs(a[nx] - a[pr]), {pr, nx}});
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto x : ans) {
    cout << x.first + 1 << ' ' << x.second + 1 << "\n";
    ;
  }
}
