$\=<>=~$";map$i+=s/ \d+/++$h{$&}[$i]/ge,`factor`;for$k(keys%h){map{($\*=$k)%=1e9+7for 1..$_}(sort{$b-$a}@{$h{$k}})[0..$'-1]}print