main=interact$f.map read.words f[y,x]=g y["1 0 ","0 1 "]>>=(++"\n").g(2*x-1) g=(.cycle).take