#include <bits/stdc++.h>
using namespace std;
inline void read() {}
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
long long arr[200007];
struct DATA {
  long long idx1, idx2, val;
  bool operator<(const DATA &prev) const {
    if (val != prev.val) return val > prev.val;
    return idx1 > prev.idx1;
  }
};
priority_queue<DATA> PQ;
DATA temp;
set<long long> available_dancers;
set<long long>::iterator it;
long long n;
string str;
void InsertPair(int id1, int id2) {
  if (id1 == id2) return;
  bool flag = 1;
  it = available_dancers.find(id1);
  if (it == available_dancers.end()) flag = 0;
  it = available_dancers.find(id2);
  if (it == available_dancers.end()) flag = 0;
  if (str[id1] == str[id2]) {
    flag = 0;
  }
  if (!flag) return;
  temp.idx1 = min(id1, id2);
  temp.idx2 = max(id1, id2);
  temp.val = abs(arr[id1] - arr[id2]);
  PQ.push(temp);
  return;
}
void call(int id1) {
  long long x, y;
  it = available_dancers.lower_bound(id1 + 1);
  if (it == available_dancers.end())
    y = -1;
  else
    y = *it;
  if (it != available_dancers.begin() && y != -1) {
    it--;
    x = *it;
  } else {
    x = -1;
  }
  InsertPair(x, y);
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  read();
  cin >> n >> str;
  for (__typeof(n) i = 0; i < (n); i++) {
    cin >> arr[i];
  }
  for (__typeof(n - 1) i = 0; i < (n - 1); i++) {
    if (str[i] != str[i + 1]) {
      temp.idx1 = i;
      temp.idx2 = i + 1;
      temp.val = abs(arr[i] - arr[i + 1]);
      PQ.push(temp);
    }
  }
  for (__typeof(n) i = 0; i < (n); i++) {
    available_dancers.insert(i);
  }
  vector<long long> res1, res2;
  while (!PQ.empty()) {
    bool f = 1;
    temp = PQ.top();
    PQ.pop();
    long long id1 = temp.idx1;
    long long id2 = temp.idx2;
    long long val = temp.val;
    it = available_dancers.find(id1);
    if (it == available_dancers.end()) f = 0;
    it = available_dancers.find(id2);
    if (it == available_dancers.end()) f = 0;
    if (f) {
      res1.push_back(id1 + 1);
      res2.push_back(id2 + 1);
      available_dancers.erase(id1);
      available_dancers.erase(id2);
      call(id1);
      call(id2);
    }
  }
  cout << ((int)res1.size()) << "\n";
  for (__typeof(((int)res1.size())) i = 0; i < (((int)res1.size())); i++) {
    cout << res1[i] << " " << res2[i] << "\n";
  }
}
