connected graph

If there are different pairs of characters, each pair of the characters
means the two matching characters are the same. Print out all the
identical characters.

For example:

if you have pairs:

A-B
C-D
E-F
G-H
A-D
F-G

you should print out:
{A, B, C, D} are the same characters.
{E, F, G, H} are the same characters.