#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, s1 = 0, s2 = 0;
  cin >> n;
  int a[n][2];
  int temp;
  for (i = 0; i < n; i++)
    for (j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  for (i = 0; i < n; i++) {
    s1 += a[i][0];
    s2 += a[i][1];
  }
  if (s1 % 2 != 0 && s2 % 2 == 0)
    cout << "-1";
  else if (s1 % 2 == 0 && s2 & 2 != 0)
    cout << "-1";
  else if (s1 % 2 == 0 && s2 % 2 == 0)
    cout << "0";
  else {
    for (i = 0; i < n; i++) {
      temp = a[i][0];
      a[i][0] = a[i][1];
      a[i][1] = temp;
      s1 = 0;
      s2 = 0;
      for (j = 0; j < n; j++) {
        s1 += a[j][0];
        s2 += a[j][1];
      }
      if (s1 % 2 == 0 && s2 % 2 == 0) {
        cout << "1";
        break;
      }
    }
  }
  if (s1 % 2 != 0 && s2 % 2 != 0) cout << -1;
  return 0;
}
