// NOTE: it is recommended to use this even if you don't understand the following code.

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAXQ 1000000
#define MAXN 1000001

int       N, Q, i;
char      S[MAXN];
int       l[MAXQ], r[MAXQ];
long long ans[MAXQ];

int main() {
    // uncomment the two following lines if you want to read/write from files
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    assert(2 == scanf("%d%d", &N, &Q));

    assert(1 == scanf("%s", S));

    for (i = 0; i < Q; ++i)
        assert(2 == scanf("%d%d", &l[i], &r[i]));



    // INSERT YOUR CODE HERE


    for (i = 0; i < Q; ++i)
        printf("%lld\n", ans[i]);

    return 0;
}
