#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int a[1000], b[1000];
    int suma = 0, sumb = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i] >> b[i];
      suma += a[i];
      sumb += b[i];
    }
    if (suma % 2 == 0 && sumb % 2 == 0) {
      cout << 0 << endl;
      ;
      continue;
    }
    if (suma % 2 != 0 && sumb % 2 != 0) {
      int flag = -1;
      for (int i = 0; i < n; ++i) {
        if ((a[i] + b[i]) % 2 == 1) {
          flag = 1;
        }
      }
      cout << flag << endl;
      continue;
    }
    cout << -1 << endl;
  }
  return 0;
}
