#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void okreni_sve(long long unsigned int l,long long unsigned int r,string s,long long unsigned int * c)
{
    
    for (auto j= l; j < r; j++)
    {
        if (s[j]=='0')
        {
            s[j]='1';
            c++;
           
        }
        else
        {
            s[j]='0';
            c--;
        }
        
    }
   
    
}
string okreni_jedan(long long unsigned int x, string s)
{
    if (s[x]=='0')
    {
        s[x]='1';
    }
    else
    {
        s[x]='0';
    }
    return s;
}
int main(int argc, const char * argv[]) {
    long long unsigned int N,Q,C;
    cin>>N>>C>>Q;
    long long unsigned int L[Q],R[Q];
    string str,s[Q];
    cin>>str;
    for (auto i =0; i < Q; i ++)
    {
        cin>>L[i]>>R[i];
        s[i]=str;
    }
    for (auto i =0; i < Q; i ++)
    {
        if (i!=0)
        {
            s[i]=s[i-1];
        }
        for (auto j= L[i]; j <= R[i]; j++)
        {
            if (s[i][j-1]=='0')
            {
                s[i][j-1]='1';
            }
            else
            {
                s[i][j-1]='0';
            }
        }
        
        
    }
    for (auto i =0; i < Q; i ++)
    {
        long long unsigned int l=0,r=N,count1=0,cena=0,count0=0;
        vector<long long unsigned int> poz1;
        do
        {
            count1=0;count0=0;r=N;l=0;
        while (s[i][l]=='0')
        {
            l++;
        }
        while (s[i][r]=='0')
        {
            r--;
        }
        for (auto j = l; j <r; j ++)
        {
            if (s[i][j]=='1')
            {
                count1 ++;
                poz1.push_back(j);
            }
            
        }
           // cout<<s[i]<<endl;
            
        if (count1 > C&&count1>r-l-count1)
        {
            
            replace( s[i].begin()+l, s[i].end()-s[i].length()+r, '1', 'x');
            replace( s[i].begin()+l, s[i].end()-s[i].length()+r, '0', '1');
            replace( s[i].begin()+l, s[i].end()-s[i].length()+r, 'x', '0');
            //cout<<s[i]<<endl;
            
            count1=r-l-count1;
          //  cout<<count1<<endl;
            cena+=C;
            if (count1==0)
            {
                break;
            }
        }
        else
        {
            for (auto j = 0 ; j <poz1.size(); j ++)
            {
               
                
                s[i][poz1[j]]='0';
               
                cena++;
                count1 --;
               // cout<<count1<<endl;
                if (count1==0)
                {
                    break;
                }
            }
        }
            //cout<<s[i]<<endl;
            if (count1==0)
            {
               // cout<<"BYee"<<endl;
                break;
            }
        }while (count1!=0) ;
        cout<<cena<<endl;
    }
    
    
    return 0;
}