#include using namespace std; int main() { int N; cin >> N; vectorA(2*N+1); for(int i = 0; i <= 2*N; i++) { cin >> A[i]; } if(2*N+1 == 3) { vector>base = {{0,1,2},{1,2,0},{2,0,1}}; if(A == base[0] || A == base[1] || A == base[2]) { cout << 1 << endl; } else { base = {{2,1,0},{1,0,2},{0,2,1}}; if(A == base[0] || A == base[1] || A == base[2]) { cout << 2 << endl; } else { cout << 0 << endl; } } return 0; } int f = A[0] != 0; for(int i = 1; i <= 2*N; i += 2) { if(A[i] != 0) { f = 0; } } if(f == 0) { cout << 0 << endl; } else { for(int i = 2; i <= 2*N; i += 2) { if(A[i] == 0 || A[i-2] == A[i]) { f = 0; } } if(f == 0) { cout << 0 << endl; } else { if(N%2 == A[0]%2) { cout << 2 << endl; } else { cout << 1 << endl; } } } }