#!/usr/bin/env python
# Tue Jun  2 13:10:15 EDT 2009

from rasmus.common import *

from rasmus.sets import UnionFind

sets = {}

for row in DelimReader(sys.stdin):
    row_sets = []
    for item in row:
        if item not in sets:
            s = UnionFind([item])
            sets[item] = s
            row_sets.append(s)
        else:
            row_sets.append(sets[item])

    if len(row_sets) > 1:
        for s in row_sets[1:]:
            row_sets[0].union(s)


# write unique sets
written = set()
for s in sets.itervalues():
    if s.root() not in written:
        written.add(s.root())
        print "\t".join(s.members())



