#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int a, b;
  int s1 = 0;
  int s2 = 0;
  int flag = 0;
  while (n--) {
    cin >> a >> b;
    if ((a & 1) != (b & 1)) flag = 1;
    s1 += a;
    s2 += b;
  }
  cerr << s1 << ' ' << s2 << endl;
  int ans = 0;
  if (s1 % 2 != s2 % 2) {
    ans = -1;
  } else {
    if (s1 % 2 == 0)
      ans = 0;
    else if (!flag)
      ans = -1;
    else
      ans = 1;
  }
  cout << ans << endl;
  return 0;
}
