#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, left = 0, right = 0;
  cin >> n;
  int arr[n][2];
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0];
    left += arr[i][0];
    cin >> arr[i][1];
    right += arr[i][1];
  }
  if (right % 2 == 0 && left % 2 == 0) {
    cout << "0";
  } else if ((right + left) % 2 == 0) {
    int type = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i][0] % 2 != arr[i][1] % 2) {
        cout << "1";
        type = 1;
        break;
      }
    }
    if (type == 0) {
      cout << "-1";
    }
  } else {
    cout << "-1";
  }
  return 0;
}
