/*
Failure is not the reason for you to stop trying
it is actually a remainder that you should
KEEP GOING
*/
#include<bits/stdc++.h>
#define ll long long
#define SaveTime ios_base::sync_with_stdio(false), cin.tie(0);
using namespace std;
int main()
{
SaveTime
int n, k, p; cin >> n >> k >> p;
int oddv = 0, evenv = 0;
for (int i = 1; i <= n; i++) {
int v,h; cin >> v >> h;
if (i%2) {
oddv+= v+h;
}
else {
evenv+= v+h;
}
}
cout << (p+oddv+k)%2+1;
}