#include <bits/stdc++.h>
using namespace std;
void init() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
long long dx[4] = {0, 1, -1, 0};
long long dy[4] = {1, 0, 0, -1};
vector<long long> adj[100005];
void read(vector<long long> &v) {
  for (auto &x : v) cin >> x;
}
void show(vector<long long> &v) {
  for (auto x : v) cout << x << " ";
}
void solve() {
  long long n;
  cin >> n;
  long long a = 0, b = 0, c = 0;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    a += x;
    b += y;
    c += ((x % 2) != (y % 2));
  }
  if (a % 2 == 0 && b % 2 == 0) {
    cout << 0;
  } else if (c > 0 && c % 2 == 0) {
    cout << 1;
  } else {
    cout << -1;
  }
}
void test() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
}
int main() {
  init();
  solve();
}
