#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int A[2][n + 1];
  for (int i = 1; i <= n; i++) cin >> A[0][i] >> A[1][i];
  int up = 0;
  int dw = 0;
  for (int i = 1; i <= n; i++) up += A[0][i], dw += A[1][i];
  if (up % 2 and !(dw % 2))
    cout << -1 << endl;
  else if (dw % 2 and !(up % 2))
    cout << -1 << endl;
  else if (!(dw % 2) and !(up % 2))
    cout << 0 << endl;
  else {
    for (int i = 1; i <= n; i++)
      if ((A[0][i] % 2 and !(A[1][i] % 2)) ||
          (A[1][i] % 2 and !(A[0][i] % 2))) {
        cout << 1 << endl;
        return 0;
      }
    cout << -1 << endl;
  }
}
