#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  set<int> X;
  for (int i = 0; i < n; i++) X.insert(i);
  map<int, pair<int, int>> mp;
  set<pair<int, int>> S;
  int c = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) continue;
    S.insert({abs(a[i] - a[i - 1]), c});
    mp[c] = {i - 1, i};
    c++;
  }
  vector<pair<int, int>> ans;
  while (!S.empty()) {
    auto p = *S.begin();
    S.erase(S.begin());
    int idx = p.second;
    int l = mp[idx].first, r = mp[idx].second;
    if (X.find(l) == X.end() || X.find(r) == X.end()) {
      if (X.find(l) == X.end()) {
        auto it1 = X.lower_bound(l);
        if (it1 == X.begin()) continue;
        l = *prev(it1);
      }
      if (X.find(r) == X.end()) {
        auto it2 = X.lower_bound(r);
        if (it2 == X.end()) continue;
        r = *it2;
      }
      if (s[l] != s[r]) {
        S.insert({abs(a[l] - a[r]), idx});
        mp[idx] = {l, r};
      }
      continue;
    }
    ans.push_back({l + 1, r + 1});
    X.erase(l);
    X.erase(r);
    auto it1 = X.upper_bound(l);
    auto it2 = X.upper_bound(r);
    if (it1 == X.begin() || it2 == X.end()) continue;
    it1 = prev(it1);
    l = *it1, r = *it2;
    if (s[l] != s[r]) {
      S.insert({abs(a[l] - a[r]), idx});
      mp[idx] = {l, r};
    }
  }
  cout << ans.size() << "\n";
  for (auto p : ans) cout << p.first << " " << p.second << "\n";
  return 0;
}
