#include "bits/stdc++.h" using namespace std; int main() { int n; cin >> n; vector x; int m, f =-1; while(n--) { int a,b,c = 0; cin >> a>> b; c = a+4*b; x.push_back(c); if (f==-1){ f = c % 2; }else if (f != c%2) { f = -1; break; } if (m < c) m = c; } if (f==-1) { cout<<-1<