import re while 1:print re.sub(r"((\d)( \2)*)",r"[\1]",raw_input())