#include using namespace std; int main() { int n; cin >> n; auto levi_civita = [](int x, int y, int z) { if(x == y or y == z or z == x) return 0; if(vector{x, y, z} == vector{0, 1, 2}) return 1; if(vector{x, y, z} == vector{1, 2, 0}) return 1; if(vector{x, y, z} == vector{2, 0, 1}) return 1; return 2; }; vector a(n * 2 + 1, 0), b(0, 0); for(auto &v : a) cin >> v; for(int i = 0; i < n * 2 - 1; i++) { b.push_back(levi_civita(a[i], a[i + 1], a[i + 2])); } auto mul2 = [](auto &vec) { auto ret = vec; for(auto &v : vec) ret.push_back(v); vec = ret; }; vector one{2, 0, 1, 0}, two{1, 0, 2, 0}; if(n % 2) swap(one, two); while(one.size() < b.size()) mul2(one); one.resize(b.size()); while(two.size() < b.size()) mul2(two); two.resize(b.size()); cout << (b == one ? 1 : b == two ? 2 : 0) << endl; }