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