while 1: x=raw_input().split().count for k in'm kg s A K mol cd'.split(): a=x(k)+2*x(k+'2') if a:print k+`a`*(a>1), print