h={} a=0 $<.sort_by{|i|rand-i[/\d+$/].hex}.map{|i|h[i[/.+ /]]||=[puts"#{a+=1;h[$'.hex]||=a} "+i]}