#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s1 = 0, s2 = 0;
  scanf("%d", &n);
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d%d", &a[i].first, &a[i].second), s1 += a[i].first,
        s2 += a[i].second;
  if (s1 % 2 == 0 && s2 % 2 == 0) {
    putchar('0');
  } else if (s1 % 2 != s2 % 2) {
    puts("-1");
  } else {
    for (int i = 0; i < n; ++i) {
      if (a[i].first % 2 != a[i].second % 2) {
        putchar('1');
        return 0;
      }
    }
    puts("-1");
  }
  return 0;
}
