#include <bits/stdc++.h>
const long long inf = 1e9 + 44;
const int MAX = 3e5 + 9;
const long long MOD = 1e9 + 7;
const double eps = 1e-10;
double const PI = 3.1415926535897931;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void _print(vector<int> v) {
  cout << "[ ";
  for (auto u : v) cout << u << " ";
  cout << " ]" << endl;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<pair<int, pair<int, int> > > st;
  int arr[n + 6], l[n + 1], r[n + 1];
  set<int> t;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    t.insert(i);
  }
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      st.insert({abs(arr[i] - arr[i - 1]), {i, i - 1}});
    }
  }
  int vis[n + 1];
  memset(vis, 0, sizeof(vis));
  vector<pair<int, int> > ans;
  while (st.size()) {
    pair<int, pair<int, int> > now = *st.begin();
    st.erase(st.begin());
    int u = now.second.first;
    int v = now.second.second;
    if (t.find(u) == t.end() || t.find(v) == t.end()) continue;
    ans.push_back(now.second);
    t.erase(u);
    t.erase(v);
    auto it = t.lower_bound(v);
    if (it != t.end()) {
      auto it1 = it;
      if (it != t.begin()) it--;
      if (s[*it] != s[*it1])
        st.insert({abs(arr[*it] - arr[*it1]), {*it1, *it}});
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].second + 1 << " " << ans[i].first + 1 << endl;
}
