s=*?# s=('1 '..$_).flat_map{l=gets.chop s.map{|m|l.gsub(/./){$&>?!?m:$&*m.size}}}while'1'