#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1 * 1e6 + 10);
int fen[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, i, a = 0, b = 0, cnt = 0, x, y;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    a += x;
    b += y;
    if (x % 2 != y % 2) cnt++;
  }
  if (a % 2 == 0 && b % 2 == 0)
    cout << 0 << endl;
  else if (cnt % 2 == 0 && cnt > 0)
    cout << 1 << endl;
  else
    cout << -1 << endl;
  return 0;
}
