#!/usr/bin/python

import sys
from unidata import *

d = dict()

CLASS_PRIORITY = ( 'F', 'C', 'S', )

for line in sys.stdin:
	if unidata_comment(line):
		continue

	tokens = line.split(';')
	codepoint, folding_type, folding = tokens[0], tokens[1], tokens[2]
	folding_type = folding_type.strip()

	try: CLASS_PRIORITY.index(folding_type.strip())
	except ValueError: continue

	codepoint = unidata_strip(codepoint)

	existing = d.get(codepoint)
	if existing is not None:
		e_folding_type, e_folding = existing
		current_priority = CLASS_PRIORITY.index(folding_type)
		existing_priority = CLASS_PRIORITY.index(e_folding_type)
		if existing_priority < current_priority:
			continue

	d[codepoint] = (folding_type, unidata_split(folding))

for codepoint, (_, folding) in sorted(d.iteritems()):
	print '%06X %s' % (int(codepoint, base=16), ','.join(folding))
