#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int u[110], l[110];
  int sumu, suml;
  while (EOF != scanf("%d", &n)) {
    sumu = suml = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &u[i], &l[i]);
      sumu += u[i];
      suml += l[i];
    }
    int ans;
    if (sumu % 2 == 0 && suml % 2 == 0) {
      ans = 0;
    } else if ((sumu + suml) % 2 == 1) {
      ans = -1;
    } else {
      ans = -1;
      for (int i = 0; i < n; i++) {
        if (u[i] % 2 != l[i] % 2) {
          ans = 1;
          break;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
