#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int SZ[maxn];
int K[maxn];
int LC[maxn];
int RC[maxn];
class SizeBalanceTree {
 public:
  void clear() {
    sz = 0;
    LC[0] = RC[0] = 0;
    SZ[0] = 0;
    root = 0;
  }
  int Size() { return SZ[root]; }
  bool empty() { return root == 0; }
  void Build(int s, int e) { Build(root, s, e); }
  bool Find(int key) { return Find(root, key); }
  void Insert(int key) { Insert(root, key); }
  void Delete(int key) { Delete(root, key); }
  int DeleteSelect(int k) { return DeleteSelect(root, k); }
  void DeleteSmall(int key) { DeleteSmall(root, key); }
  int Rank(int key) { return Rank(root, key); }
  int Select(int k) { return Select(root, k); }
  int pred(int key) { return pred(root, key); }
  int succ(int key) { return succ(root, key); }
  int getMin() {
    int temp = root;
    while (LC[temp]) temp = LC[temp];
    return K[temp];
  }
  int getMax() {
    int temp = root;
    while (RC[temp]) temp = RC[temp];
    return K[temp];
  }
  int DeleteMax() {
    int temp = root;
    if (RC[root] == 0) {
      root = LC[root];
      return K[temp];
    }
    while (RC[RC[temp]]) {
      SZ[temp]--;
      temp = RC[temp];
    }
    SZ[temp]--;
    int ret = K[RC[temp]];
    RC[temp] = LC[RC[temp]];
    return ret;
  }
  int DeleteMin() {
    int temp = root;
    if (LC[root] == 0) {
      root = RC[root];
      return K[temp];
    }
    while (LC[LC[temp]]) {
      SZ[temp]--;
      temp = LC[temp];
    }
    SZ[temp]--;
    int ret = K[LC[temp]];
    LC[temp] = RC[LC[temp]];
    return ret;
  }

 public:
  int root, sz;
  void Build(int &root, int s, int e) {
    if (s > e) return;
    int mid = (s + e) / 2;
    root = ++sz;
    K[root] = mid;
    LC[root] = 0;
    RC[root] = 0;
    SZ[root] = e - s + 1;
    if (s == e) return;
    Build(LC[root], s, mid - 1);
    Build(RC[root], mid + 1, e);
  }
  bool Find(int &root, int key) {
    if (root == 0) {
      return false;
    } else if (key < K[root]) {
      return Find(LC[root], key);
    } else {
      return (K[root] == key || Find(RC[root], key));
    }
  }
  void Insert(int &root, int key) {
    if (root == 0) {
      root = ++sz;
      LC[root] = RC[root] = 0;
      SZ[root] = 1;
      K[root] = key;
      return;
    }
    SZ[root]++;
    if (key < K[root]) {
      Insert(LC[root], key);
    } else {
      Insert(RC[root], key);
    }
    maintain(root, !(key < K[root]));
  }
  int Delete(int &root, int key) {
    SZ[root]--;
    if ((K[root] == key) || (key < K[root] && LC[root] == 0) ||
        (K[root] < key && RC[root] == 0)) {
      int ret = K[root];
      if (LC[root] == 0 || RC[root] == 0) {
        root = LC[root] + RC[root];
      } else {
        K[root] = Delete(LC[root], K[root] + 1);
      }
      return ret;
    } else {
      if (key < K[root]) {
        return Delete(LC[root], key);
      } else {
        return Delete(RC[root], key);
      }
    }
  }
  void DeleteSmall(int &root, int key) {
    if (root == 0) return;
    if (K[root] < key) {
      root = RC[root];
      DeleteSmall(root, key);
    } else {
      DeleteSmall(LC[root], key);
      SZ[root] = 1 + SZ[LC[root]] + SZ[RC[root]];
    }
  }
  int Rank(int &root, int key) {
    if (root == 0) return 0;
    if (K[root] == key) {
      return Rank(LC[root], key) + 1;
    } else if (key < K[root]) {
      return Rank(LC[root], key);
    } else {
      return SZ[LC[root]] + 1 + Rank(RC[root], key);
    }
  }
  int Select(int &root, int k) {
    if (SZ[LC[root]] + 1 == k) {
      return K[root];
    } else if (k > SZ[LC[root]]) {
      return Select(RC[root], k - 1 - SZ[LC[root]]);
    } else {
      return Select(LC[root], k);
    }
  }
  int DeleteSelect(int &root, int k) {
    SZ[root]--;
    if (SZ[LC[root]] + 1 == k) {
      int ret = K[root];
      if (LC[root] == 0 || RC[root] == 0) {
        root = LC[root] + RC[root];
      } else {
        K[root] = Delete(LC[root], K[root] + 1);
      }
      return ret;
    } else if (k > SZ[LC[root]]) {
      return DeleteSelect(RC[root], k - 1 - SZ[LC[root]]);
    } else {
      return DeleteSelect(LC[root], k);
    }
  }
  int pred(int &root, int key) {
    if (root == 0) {
      return key;
    } else if (key > K[root]) {
      int ret = pred(RC[root], key);
      if (ret == key) return K[root];
      return ret;
    } else {
      return pred(LC[root], key);
    }
  }
  int succ(int &root, int key) {
    if (root == 0) {
      return key;
    } else if (K[root] > key) {
      int ret = succ(LC[root], key);
      if (ret == key) return K[root];
      return ret;
    } else {
      return succ(RC[root], key);
    }
  }
  void LeftRotate(int &root) {
    int temp = RC[root];
    RC[root] = LC[temp];
    LC[temp] = root;
    SZ[temp] = SZ[root];
    SZ[root] = 1 + SZ[LC[root]] + SZ[RC[root]];
    root = temp;
  }
  void RightRotate(int &root) {
    int temp = LC[root];
    LC[root] = RC[temp];
    RC[temp] = root;
    SZ[temp] = SZ[root];
    SZ[root] = 1 + SZ[LC[root]] + SZ[RC[root]];
    root = temp;
  }
  void maintain(int &root, bool flag) {
    if (root == 0) return;
    if (!flag) {
      if (SZ[LC[LC[root]]] > SZ[RC[root]]) {
        RightRotate(root);
      } else if (SZ[RC[LC[root]]] > SZ[RC[root]]) {
        LeftRotate(LC[root]);
        RightRotate(root);
      } else {
        return;
      }
    } else {
      if (SZ[RC[RC[root]]] > SZ[LC[root]]) {
        LeftRotate(root);
      } else if (SZ[LC[RC[root]]] > SZ[LC[root]]) {
        RightRotate(RC[root]);
        LeftRotate(root);
      } else {
        return;
      }
    }
    maintain(LC[root], false);
    maintain(RC[root], true);
    maintain(root, false);
    maintain(root, true);
  }
};
int n;
struct ab {
  int a;
  int b;
  int val;
  bool operator<(const ab &A) const {
    if (A.val < val) return 1;
    if (A.val == val && A.a < a) return 1;
    if (A.val == val && A.a == a && A.b < b) return 1;
    return 0;
  }
} temp, now;
struct abc {
  int a;
  int b;
} ans[maxn];
int an;
bool vis[200005];
int data[200005];
char str[200005];
int main() {
  int i, len;
  while (scanf("%d", &n) != EOF) {
    memset(vis, 0, sizeof(vis));
    SizeBalanceTree sbt;
    sbt.clear();
    priority_queue<ab> que;
    scanf("%s", &str);
    for (i = 0; i < n; i++) {
      scanf("%d", &data[i]);
      sbt.Insert(i);
    }
    an = 0;
    for (i = 0; i < n - 1; i++) {
      if (str[i] != str[i + 1]) {
        temp.a = i;
        temp.b = i + 1;
        temp.val = abs(data[i] - data[i + 1]);
        que.push(temp);
      }
    }
    while (!que.empty()) {
      now = que.top();
      que.pop();
      if (vis[now.a] == 0 && vis[now.b] == 0) {
        ans[an].a = now.a;
        ans[an].b = now.b;
        an++;
        vis[now.a] = 1;
        vis[now.b] = 1;
        int zuo = sbt.pred(now.a);
        int you = sbt.succ(now.b);
        if (zuo != now.a && you != now.b) {
          if (str[zuo] != str[you]) {
            temp.a = zuo;
            temp.b = you;
            temp.val = abs(data[zuo] - data[you]);
            que.push(temp);
          }
        }
        sbt.Delete(now.a);
        sbt.Delete(now.b);
      }
    }
    printf("%d\n", an);
    for (i = 0; i < an; i++) {
      printf("%d %d\n", ans[i].a + 1, ans[i].b + 1);
    }
  }
}
