#! python3

text = """
2>4
1>2
2>3
3>5
3>1
1>4
4>2
"""

import re
tokens = re.split(r"\s+|>", text.strip())

id = {}
count = {}
out = []
for token in tokens:
	if token not in id:
		id[token] = len(id) + 1
		count[token] = 1
	else:
		count[token] += 1
	out.append((id[token], count[token]))
	
for i in range(0, len(out), 2):
	print("{}.{}>{}.{}".format(out[i][0], out[i][1], out[i + 1][0], out[i + 1][1]))
