#include <bits/stdc++.h>

using namespace std;


// SEST SEDAM

int main()
{
    iostream::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, q;
    cin >> n >> q;
    string sestsedam, sestsedam67;
    cin >> sestsedam;
    bool pitanja = true;
    for (int i = 0; i < n; i++) {
        if (sestsedam[i] != '?') {
            pitanja = false; 
            break;
        }
    }
    while (q--) {
        // setup
        int l, r;
        int sest0 = 0, sedam0 = 0;
        cin >> l >> r;
        sestsedam67 = "";
        if (pitanja) {
            cout << (r - l + 1) / 2 + ((r - l + 1) - (r - l + 1) / 2);
            continue;
        }
        cout << sestsedam67 << endl;

        // brojac 6 i 7
        int sest = 0, sedam = 0;
        int br67 = 0;
        for (int i = 0; i < r - l + 1; i++) {
            if (sestsedam67[i] == '6') sest++;
            else if (sestsedam67[i] == '7') {
                sedam++;
                br67 += sest;
            }
        }

        if (sest + sedam == r - l + 1);

        // svi ?
        /*
        else if (sest == 0 && sedam == 0) {
            for (int i = 0; i < r - l + 1; i++) {
                if (i < n / 2) sest++;
                else sedam++;
                br67 = sest * sedam;
            }
        }*/

        else {
            if (sestsedam67[r - l] == '?') sestsedam67[r - l] = '7';
            int sest2 = 0;
            int sedam2 = 0;
            for (int i = 0; i < r - l + 1)
            
        }
        cout << br67 << "\n";
    }
    return 0;
}