#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n,k,m;
cin>>n>>k>>m;
vector<pair<int,int>>p(n);
bool bol=false;ll sum=0,bol2=false;
for(int i=0;i<n;i++){
cin>>p[i].first>>p[i].second;
if(p[i].first%2!=p[i].second%2) bol=true;
else bol2=true;
sum+=p[i].first;
}
if(k%2==0)
{
if(bol&&bol2)
cout<<2;
else
cout<<(m%2==sum%2?1:2)<<endl;
}
else
{
if(bol&&bol2)cout<<1<<endl;
else if(bol) cout<<(m%2==sum%2?2:1)<<endl;
else
cout<<(m%2==sum%2?1:2)<<endl;
}
return 0;
}