#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; int main() { int N; scanf("%d", &N); bitset<200010> bit_0, bit_1, bit_2; int a; for(int i = 0; i < 2 * N + 1; i++) { scanf("%d", &a); // cout << a << endl; if(a == 0) { bit_0.set(i); } else if(a == 1) { bit_1.set(i); } else { bit_2.set(i); } } // cout << -1 << " 0 " << bit_0.any() << endl; // cout << -1 << " 1 " << bit_1.any() << endl; // cout << -1 << " 2 " << bit_2.any() << endl; bitset<200010> new_bit_0, new_bit_1, new_bit_2, bit_01, bit_10; for(int i = 0; i < N; i++) { bit_01 = (bit_0 & (bit_1 >> 1)); new_bit_1 = (bit_01 & (bit_2 >> 2)) | (bit_1 & (bit_2 >> 1) & (bit_0 >> 2)) | (bit_2 & (bit_01 >> 1)); bit_10 = (bit_1 & (bit_0 >> 1)); new_bit_2 = (bit_0 & (bit_2 >> 1) & (bit_1 >> 2)) | (bit_2 & (bit_10 >> 1)) | (bit_10 & (bit_2 >> 2)); swap(bit_1, new_bit_1); swap(bit_2, new_bit_2); bit_0 = (bit_1 ^ bit_2).flip(); } if(bit_1.any()) putchar('1'); else if(bit_2.any()) putchar('2'); else putchar('0'); return 0; }