#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n][2];
  int arr2[n];
  int sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0] >> arr[i][1];
    sum1 += arr[i][0];
    sum2 += arr[i][1];
    if ((arr[i][0] % 2 == 0 && arr[i][1] % 2 == 0) ||
        (arr[i][0] % 2 == 1 && arr[i][1] % 2 == 1)) {
      arr2[i] = 1;
    } else
      arr2[i] = 0;
  }
  int m = 1, r = 1;
  if (sum1 % 2 == 0 && sum2 % 2 == 0) {
    cout << "0" << endl;
    exit(0);
  } else if ((sum1 + sum2) % 2 == 1) {
    cout << "-1" << endl;
    exit(0);
  } else
    for (int i = 0; i < n; i++) {
      if (arr2[i] == 0) {
        m = sum1 - arr[i][0] + arr[i][1];
        r = sum2 - arr[i][1] + arr[i][0];
        if (m % 2 == 0 && r % 2 == 0) {
          cout << "1" << endl;
          exit(0);
        }
      }
    }
  cout << "-1" << endl;
  return 0;
}
