print(io.read'*a':gsub("%d+(%d)[%1 ][%d ]+","%1"))