#C2116. Identifying the Hub Atom in a Molecular Web
Identifying the Hub Atom in a Molecular Web
Identifying the Hub Atom in a Molecular Web
You are given a set of bonds in a molecular structure. Each bond connects two atoms and also includes an extra number (which should be ignored). Your task is to determine the hub atom, defined as the atom with the lexicographically smallest label among all unique atoms appearing in the bonds.
The lexicographical order follows the usual order of strings. For instance, if the bonds are:
A B 1 B C 2 C D 3
then the set of unique atoms is {A, B, C, D} and the hub atom is A
because it comes first in lexicographic order.
Your solution should read input from stdin and output the answer to stdout.
inputFormat
The input starts with a single integer \(M\) representing the number of bonds. Each of the following \(M\) lines contains two strings and an integer (the integer is not used). For example:
3 A B 1 B C 2 C D 3
outputFormat
Output a single string: the lexicographically smallest atom label (i.e. the hub atom) among all atoms from the input.
## sample3
A B 1
B C 2
C D 3
A