#include using namespace std; int main() { int n; cin >> n; n = n * 2 + 1; int a[200005]; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n - 4; i++){ if(a[i] != a[i + 4]){ cout << 0 << endl; return 0; } } for(int i = 1; i < n - 2; i += 2){ if(a[i] != a[i + 2]){ cout << 0 << endl; return 0; } } if(n % 4 == 1){ if((a[0] + 1) % 3 == a[1] && (a[1] + 1) % 3 == a[2]) cout << 2 << endl; else if((a[0] + 2) % 3 == a[1] && (a[1] + 2) % 3 == a[2]) cout << 1 << endl; else cout << 0 << endl; } else{ if((a[0] + 1) % 3 == a[1] && (a[1] + 1) % 3 == a[2]) cout << 1 << endl; else if((a[0] + 2) % 3 == a[1] && (a[1] + 2) % 3 == a[2]) cout << 2 << endl; else cout << 0 << endl; } }