#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define LL long long
#define LD long double
#define pb push_back
#define F first
#define S second
const double PI=3.1415926535897932384626433;
const int KL=1e6;
const LL MOD=1e9+7;
using namespace std;
/*
typedef complex<double> point;
#define x real()
#define y imag()
*/
LL q,x,y,z,n,m,a[KL],mn=1e9,mx=-1e9,ans,k;
string t;
vector <LL> vec;
set <LL> s;
map <LL,LL> mp;
int main()
{
scl(n);scl(k);scl(m);
LL sum1=0,sum2=0;
bool ok=false;
bool flag=false;
for(int i=0;i<n;i++){
scl(x);scl(y);
sum1=(sum1+x)%2;
sum2=(sum2+y)%2;
if(x%2!=y%2)ok=1;
if(x%2==y%2)flag=1;
}
if(ok==0){
if(sum1==m)cout<<1<<endl;
else cout<<2<<endl;
return 0;
}
if(k%2==1){
cout<<1<<endl;
}
else cout<<2<<endl;
return 0;
}
Copy