#include <bits/stdc++.h>

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    string t = "";
    for(int i = 0; i < n; i++)
    {
        t += '?';
    }
    if(s == t)
    {
        vector<int> v(0);
        for(int i = 0; i < q; i++)
        {
            int a,b;
            cin >> a >> b;
            if((a-b+1) % 2 == 0){
                v.push_back(((b-a+1)/2)*((b-a+1)/2));
            }
            else{
                v.push_back(((b-a+1)/2)*((b-a+1)/2+1));
            }
        }
        for(int x : v)
        {
            cout << x << endl;
        }
    }

}