Computer programs are usually built from several modules, and compiling such a program is normally done in two stages.
First, each source module is compiled independently into an object module. An object module has three parts:
The export table lists the symbols (for example, variable or function names) that this module defines and that other modules are allowed to use. The import table lists the external symbols that this module depends on.
After every module has been compiled, a program called the linker combines them into a single executable.
Every program has an entry point: the place where execution begins. The entry point is a symbol, and the module that "contains" it is the module that exports that symbol. To make the executable smaller, the linker keeps only the module that contains the entry point together with every module it depends on, directly or transitively; all other modules are called redundant.
Dependencies are expressed through symbols: a module depends on another module when it imports a symbol that the other module exports. If a symbol is exported by several modules, then a module importing that symbol depends on all of them.
Given the description of every module, report:
If the entry-point symbol is not exported by any module, it is treated as an unresolved import as well; in that case no module contains the entry point, so there are no non-redundant modules.
The first line contains the name of the entry point.
The second line contains the number of modules $N$ ($1 \le N \le 100$).
After that come $N$ blocks, one per module:
Every name in this problem is a non-empty string of at most $30$ characters made up of latin letters and digits.
Print the non-redundant modules, then the duplicate exports, then the unresolved imports. To make the answer unique, print each group in a fixed order:
In ASCII order, digits come before uppercase letters, which come before lowercase letters.