#include <bits/stdc++.h>
using namespace std;
int x1, x2, n, y, z;
bool t;
int main() {
  cin >> n;
  while (n--) {
    cin >> y;
    x1 += y;
    cin >> z;
    x2 += z;
    if (z % 2 != y % 2) {
      t = true;
    }
  }
  if ((x1 + x2) % 2 == 1 || (x1 == 1 && x2 == 1)) {
    cout << "-1" << endl;
  } else if (x1 % 2 == 0) {
    cout << "0" << endl;
  } else if (t) {
    cout << "1" << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}
