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