#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, c, q; cin >> n >> c >> q;
    string s; cin >> s;

    if (c == 1) {
        for (int i = 0; i < q; ++i) {
            int li, ri; cin >> li >> ri; --li; --ri;
            for (int i = li; i <= ri; ++i)
                if (s[i] == '1') s[i] = '0';
                else s[i] = '1';

            int brGrupica = 0;
            for (int i = 0; i < n; ++i) {
                if (s[i] == '1') {
                    brGrupica++;
                    while (s[i] == '1') ++i;
                }
            }

            int brNula = 0; for (int i = 0; i < n; ++i) if (s[i] == '0') ++brNula;

            cout << min(brNula, brGrupica) << endl;
        }
    } else {
        for (int i = 0; i < q; ++i) {
            int li, ri; cin >> li >> ri; --li; --ri;
            cout << rand()%n+1 << endl;
        }
    }

    return 0;
}