```go
package main
import "fmt"
func main() {
var n int
if _, err := fmt.Scan(&n); err != nil {
return
}
sumTop, sumBot := 0, 0
canSwap := false
for i := 0; i < n; i++ {
var x, y int
fmt.Scan(&x, &y)
sumTop += x
sumBot += y
if (x%2) != (y%2) {
canSwap = true
}
}
if sumTop%2 == 0 && sumBot%2 == 0 {
fmt.Println(0)
} else if sumTop%2 != 0 && sumBot%2 != 0 && canSwap {
fmt.Println(1)
} else {
fmt.Println(-1)
}
}
```