#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4 * atan(1);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, u_sum = 0, l_sum = 0, u, l, c = 0;
  cin >> n;
  while (n--) {
    cin >> u >> l;
    u_sum += u;
    l_sum += l;
    if (u % 2 != l % 2) c++;
  }
  if (u_sum % 2 == 0 && l_sum % 2 == 0)
    cout << 0;
  else if (u_sum % 2 == l_sum % 2 && c > 0)
    cout << 1;
  else
    cout << -1;
  cout << "\n";
  ;
  return 0;
}
