#include<bits/stdc++.h>
using namespace std;
int N,C,Q,L,R,sol;
string s;
int main(){
  cin>>N>>C>>Q;
  cin>>s;
  while(Q--){
    cin>>L>>R;
    sol=0;
    for(int i=L-1; i<R; i++)
      s[i]=(s[i]-'0'+1)%2+'0';
    cout<<s<<endl;
    int proslip=0;
    int proslik=-1;
    int sadp=0;
    int sadk=0;
    bool sac=false;
    for(int i=0; i<s.size(); i++){
      if(s[i]=='0')continue;
      sadp=i;
      while(i<s.size() and s[i]=='1')i++;
      sadk=i-1;
      int op3=sadk-sadp+1;
      int op2=C;
      int op1=(sadp-proslik-1);
      if(sac==false)op1+=C-(proslik-proslip+1);
      if(op1<=op2 and op1<=op3){
        sac=true;
        sol+=op1;
        proslik=sadk;
      }
      if(op2<op1 and op2<=op3){
        sac=true;
        sol+=op2;
        proslip=sadp;
        proslik=sadk;
      }
      if(op1>op3 and op2>op3){
        sac=false;
        sol+=op3;
        proslip=sadp;
        proslik=sadk;
      }
    }
    cout<<sol<<endl;
  }

  return 0;
}