#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long a[n][2];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  long long sum1 = 0, k = 0, sum2 = 0;
  for (long long i = 0; i < n; i++) {
    sum1 += a[i][0];
    sum2 += a[i][1];
  }
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << 0 << endl;
  } else if (sum1 % 2 != 0 && sum2 % 2 == 0 || sum1 % 2 == 0 && sum2 % 2 != 0) {
    cout << -1 << endl;
  } else {
    long long flag = 0;
    for (long long i = 0; i < n; i++) {
      if ((a[i][0] % 2 != 0 && a[i][1] % 2 == 0) ||
          (a[i][0] % 2 == 0 && a[i][1] % 2 != 0)) {
        cout << 1 << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << -1 << endl;
    }
  }
}
