a=*?# a=('1 '..$_).flat_map{gets a.map{|s|$_.chop.gsub(/./){s.tr ?#,$&}}}while gets>?1 puts a