#include <bits/stdc++.h>
using namespace std;
void out (int x) {
cout << x;
exit(0);
}
int main (){
#ifndef ONLINE_JUDGE
freopen("SuhaibSawalha1","r",stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k, p;
cin >> n >> k >> p;
k &= 1;
long long s = 0;
array<int, 2> a[n];
int keep = 0, change = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i][0] >> a[i][1];
s += a[i][0];
keep += a[i][0] % 2 == a[i][1] % 2;
change += a[i][0] % 2 != a[i][1] % 2;
}
if ((s & 1) == p) {
if (!change) {
out(1);
}
if (!keep) {
out(k ? 2 : 1);
}
out(k ? 1 : 2);
}
if (!change) {
out(2);
}
if (!keep) {
out(k ? 1 : 2);
}
out(k ? 1 : 2);
return 0;
}
Copy