#include<bits/stdc++.h>
using namespace std;
int f(int n) {
    int b=1;
    while (n>1) {
        b*=n;
        n--;
    }
    return b;
}
int main() {
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    for (int i=0; i<q; i++) {
        int l,r;
        cin>>l>>r;
        int m=abs(l-r)+1;
        if (m%2==0) {
            cout<<f(m/2);
        }
        else {
            int h=m/2+1;
            cout<<h*(h+1)/2-1;
        }
    }
}