def parity(n) n<1 ? 0 : n%1+parity(n/2) end n=gets.to_i m=n.times.map{|i|gets.split.map &:to_i} r=[0]*(1<