'use strict';

function Main(input) {
    input = input.split("\n");
    const tmp = input[1].split("");
    let lastA = false;
    let count = Number(0);
    let acarray = tmp.map(x => {
        if (x === "C" && lastA) {
            count++;
            return count;
        }
        if (x === "A") {
            lastA = true;
            return count;
        }
        lastA = false;
        return count;

    });
    let question = input.slice(2);
    for (const q of question) {
        const qv = q.split(" ").map(x=>parseInt(x) - 1);
        const res = Number(acarray[qv[1]] - acarray[qv[0]]);
        console.log(res);
        console.log(0);
        console.log(3);
        return;
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
