import java.io.*;
import java.util.*;
class StringQueries {
int N = re.nextInt();
int Q = re.nextInt();
int pre[][] = new int[26][N+1];
for(int i=0; i<26; i++){
pre[i][0] = 0;
for(int j=0; j<N; j++){
pre[i][j+1] = pre[i][j];
if(S.charAt(j)=='a'+i)
pre[i][j+1]++;
}
}
while(Q-->0){
int L = re.nextInt();
int R = re.nextInt();
int f[] = new int[26];
for(int i=0; i<26; i++)
f[i] = pre[i][R]-pre[i][L-1];
int m = (int)1e6;
for(int i=0; i<26; i++){
int d = 0, k = f[i];
for(int j=0; j<26; j++){
if(f[j]<f[i])
d += f[j];
else
d += f[j]-k;
}
}
}
}
}
int p;
p = 0;
}
while(p==words.length){
words = br.readLine().split("\\s+");
p = 0;
}
}
ensureInput();
return words[p++];
}
}
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgU3RyaW5nUXVlcmllcyB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKXRocm93cyBFeGNlcHRpb24gewogICAgICAgIFJlYWRlciByZSA9IG5ldyBSZWFkZXIoU3lzdGVtLmluKTsKICAgICAgICBpbnQgTiA9IHJlLm5leHRJbnQoKTsKICAgICAgICBpbnQgUSA9IHJlLm5leHRJbnQoKTsKICAgICAgICBTdHJpbmcgUyA9IHJlLm5leHQoKTsKICAgICAgICAKICAgICAgICBpbnQgcHJlW11bXSA9IG5ldyBpbnRbMjZdW04rMV07CiAgICAgICAgZm9yKGludCBpPTA7IGk8MjY7IGkrKyl7CiAgICAgICAgICAgIHByZVtpXVswXSA9IDA7CiAgICAgICAgICAgIGZvcihpbnQgaj0wOyBqPE47IGorKyl7CiAgICAgICAgICAgICAgICBwcmVbaV1baisxXSA9IHByZVtpXVtqXTsKICAgICAgICAgICAgICAgIGlmKFMuY2hhckF0KGopPT0nYScraSkKICAgICAgICAgICAgICAgICAgICBwcmVbaV1baisxXSsrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIAogICAgICAgIHdoaWxlKFEtLT4wKXsKICAgICAgICAgICAgaW50IEwgPSByZS5uZXh0SW50KCk7CiAgICAgICAgICAgIGludCBSID0gcmUubmV4dEludCgpOwogICAgICAgICAgICBpbnQgZltdID0gbmV3IGludFsyNl07CiAgICAgICAgICAgIGZvcihpbnQgaT0wOyBpPDI2OyBpKyspCiAgICAgICAgICAgICAgICBmW2ldID0gcHJlW2ldW1JdLXByZVtpXVtMLTFdOwogICAgICAgICAgICAKICAgICAgICAgICAgaW50IG0gPSAoaW50KTFlNjsKICAgICAgICAgICAgZm9yKGludCBpPTA7IGk8MjY7IGkrKyl7CiAgICAgICAgICAgICAgICBpbnQgZCA9IDAsIGsgPSBmW2ldOwogICAgICAgICAgICAgICAgZm9yKGludCBqPTA7IGo8MjY7IGorKyl7CiAgICAgICAgICAgICAgICAgICAgaWYoZltqXTxmW2ldKQogICAgICAgICAgICAgICAgICAgICAgICBkICs9IGZbal07CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBkICs9IGZbal0tazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG0gPSBNYXRoLm1pbihtLCBkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKG0pOwogICAgICAgIH0KICAgIH0KfQoKCmNsYXNzIFJlYWRlcnsKICAgIEJ1ZmZlcmVkUmVhZGVyIGJyOwogICAgU3RyaW5nIHdvcmRzW107CiAgICBpbnQgcDsKICAgIFJlYWRlcihJbnB1dFN0cmVhbSBpbil7CiAgICAgICAgYnIgPSBuZXcgQnVmZmVyZWRSZWFkZXIobmV3IElucHV0U3RyZWFtUmVhZGVyKGluKSk7CiAgICAgICAgd29yZHMgPSBuZXcgU3RyaW5nW117fTsKICAgICAgICBwID0gMDsKICAgIH0KCiAgICB2b2lkIGVuc3VyZUlucHV0KCkgdGhyb3dzIEV4Y2VwdGlvbnsKICAgICAgICB3aGlsZShwPT13b3Jkcy5sZW5ndGgpewogICAgICAgICAgICB3b3JkcyA9IGJyLnJlYWRMaW5lKCkuc3BsaXQoIlxccysiKTsKICAgICAgICAgICAgcCA9IDA7CiAgICAgICAgfQogICAgfQoKICAgIFN0cmluZyBuZXh0KCkgdGhyb3dzIEV4Y2VwdGlvbnsKICAgICAgICBlbnN1cmVJbnB1dCgpOwogICAgICAgIHJldHVybiB3b3Jkc1twKytdOwogICAgfQoKICAgIGludCBuZXh0SW50KCkgdGhyb3dzIEV4Y2VwdGlvbnsKICAgICAgICByZXR1cm4gSW50ZWdlci5wYXJzZUludChuZXh0KCkpOwogICAgfQp9