($n,$k)=glob<>;print map{/\w+$/g,$/}(sort map s/u/sprintf"%8d",++$v[$']/er,sort map{($s,$p,$u)=glob;sprintf"%8du%8d%8d %d",1e5-$s,$u,$p,$i++}<>)[0..$k-1]