#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, n, s_x = 0, s_y = 0, flag = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if ((x % 2 == 0 && y % 2 == 1) || (x % 2 == 1 && y % 2 == 0)) flag = 1;
    s_x += x;
    s_y += y;
  }
  if (s_x % 2 == 0 && s_y % 2 == 0)
    cout << 0;
  else if (s_x % 2 == 1 && s_y % 2 == 1 && flag)
    cout << 1;
  else
    cout << -1;
  return 0;
}
