gets;k=->i{z=$_.split.map{|e|e.to_i%i};z.sort[1]!=z[1]&&z|[]==z} $><