n,*a=(gets+gets).split.map(&:to_i);z=[];n.times{|i|n.times{|j|if a[i]