#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return a == 0 ? b : gcd(b % a, a);
}
template <class T>
string tostring(T a) {
  ostringstream os;
  os << a;
  return os.str();
}
int toint(string a) {
  istringstream is(a);
  int p;
  is >> p;
  return p;
}
long long toll(string a) {
  istringstream is(a);
  long long p;
  is >> p;
  return p;
}
string s;
vector<int> sk;
vector<int> ne, fr;
vector<bool> used;
int main() {
  int n;
  cin >> n >> s;
  sk.resize(n);
  for (int i = 0; i < n; i++) cin >> sk[i];
  ne.resize(n);
  fr.resize(n);
  for (int i = 0; i < n - 1; i++) ne[i] = i + 1, fr[i + 1] = i;
  ne[n - 1] = -1;
  fr[0] = -1;
  used.resize(n, false);
  set<pair<int, pair<int, int> > > se;
  for (int i = 0; i < n - 1; i++)
    if (s[i] != s[i + 1])
      se.insert(make_pair(abs(sk[i] - sk[i + 1]), make_pair(i, i + 1)));
  vector<pair<int, int> > res;
  while (se.size() > 0) {
    pair<int, pair<int, int> > x = *se.begin();
    se.erase(se.begin());
    if (used[x.second.first] || used[x.second.second]) continue;
    res.push_back(x.second);
    if (fr[x.second.first] != -1) ne[fr[x.second.first]] = ne[x.second.second];
    if (ne[x.second.second] != -1) fr[ne[x.second.second]] = fr[x.second.first];
    if (fr[x.second.first] != -1 && ne[x.second.second] != -1 &&
        s[fr[x.second.first]] != s[ne[x.second.second]])
      se.insert(make_pair(abs(sk[fr[x.second.first]] - sk[ne[x.second.second]]),
                          make_pair(fr[x.second.first], ne[x.second.second])));
    used[x.second.first] = used[x.second.second] = true;
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++)
    cout << res[i].first + 1 << " " << res[i].second + 1 << endl;
}
