public void solve() throws IOException {
    int n = nextInt();
    int eo = 0;
    int sum1 = 0;
    int sum2 = 0;
    for (int x = 0; x < n; x++) {
      int a = nextInt();
      int b = nextInt();
      sum1 += a;
      sum2 += b;
      if (a % 2 != b % 2)
        eo++;
    }
    sum1 %= 2;
    sum2 %= 2;
    if (sum1 == 0 && sum2 == 0)
      System.out.println(0);
    else if (sum1 == 1 && sum2 == 1) {
      if (eo >= 1 && n > 1)
        System.out.println(1);
      else
        System.out.println(-1);
    } else {
      System.out.println(-1);
    }

  }