#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
set<pair<int, pair<int, int>>> s;
set<pair<int, pair<int, int>>>::iterator it;
vector<pair<int, int>> ans;
int n, v[N], nex[N], last[N];
char a[N];
bool checking[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  scanf("%d%s", &n, a + 1);
  for (int i = 1; i <= n; ++i) scanf("%d", &v[i]);
  for (int i = 1; i <= n; ++i)
    nex[i] = i + 1, last[i] = i - 1, checking[i] = true;
  for (int i = 1; i < n; ++i) {
    if (a[i] ^ a[i + 1])
      s.insert(make_pair(abs(v[i] - v[i + 1]), make_pair(i, i + 1)));
  }
  while (s.size()) {
    it = s.begin();
    int x = (*it).second.first;
    int y = (*it).second.second;
    s.erase(it);
    if (checking[x] && checking[y])
      ans.push_back(make_pair(x, y)), checking[x] = checking[y] = false;
    else {
      continue;
    }
    int p = last[x];
    int q = nex[y];
    nex[p] = q;
    last[q] = p;
    if (p <= n && p >= 1 && q <= n && q >= 1 && a[p] ^ a[q]) {
      s.insert(make_pair(abs(v[p] - v[q]), make_pair(p, q)));
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); ++i)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
