c,g=p~-$<.read.split(?\n).count{|s|x,y=s.split.map &:to_i;g ? y&&g>0&&x%g<1&&y%g<1&&(x-y)*c/g%2<1:(c=x*y/g/g%2if 0