#include <bits/stdc++.h>
using namespace std;
int main() {
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      q;
  int n;
  unordered_set<int> s;
  set<int> unseen;
  cin >> n;
  string str;
  cin >> str;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    unseen.insert(i);
  }
  for (int i = 0; i < str.length() - 1; i++) {
    if (str[i] != str[i + 1])
      q.push(make_pair(abs(arr[i] - arr[i + 1]), make_pair(i, i + 1)));
  }
  vector<pair<int, int>> res;
  while (!q.empty()) {
    pair<int, pair<int, int>> curr = q.top();
    q.pop();
    if (s.find(curr.second.first) != s.end() ||
        s.find(curr.second.second) != s.end())
      continue;
    s.insert(curr.second.first);
    s.insert(curr.second.second);
    res.push_back(curr.second);
    int i = curr.second.first;
    int j = curr.second.second;
    auto prevI = unseen.lower_bound(i);
    auto nextJ = unseen.upper_bound(j);
    if (prevI == unseen.begin() || nextJ == unseen.end()) {
      unseen.erase(i);
      unseen.erase(j);
      continue;
    }
    int pi = *(--prevI);
    int nj = *nextJ;
    if (str[pi] != str[nj]) {
      q.push(make_pair(abs(arr[pi] - arr[nj]), make_pair(pi, nj)));
    }
    unseen.erase(i);
    unseen.erase(j);
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) {
    cout << res[i].first + 1 << " " << res[i].second + 1 << endl;
  }
  return 0;
}
