Subdictionary#6911

Subdictionary

1 second
64 megabytes
Very easy

In this problem, a "dictionary" is defined as a list of words in alphabetical order, where each word has an explanation written in the same language. The dictionary must include the definition for every word that appears in the explanation of any other word in the dictionary. If a dictionary provides definitions for words, the dictionary contains exactly distinct words. It is also given that no word appears in the definition of itself.

A subdictionary is a subset of the dictionary's words and their definitions such that it can be published as an independent dictionary, still satisfying the above conditions. As a Computational Linguistics course project, you are tasked with creating a Lexical Knowledge Base, which is the knowledge represented by words. For this, you need to build your knowledge base using a dictionary.

It is difficult for a computer to study words automatically. Therefore, we decided to manually teach it some common words. We start with an appropriate subdictionary. Once it understands the words in this set, the computer could extend its knowledge to the whole dictionary, word by word. For example, the computer can learn the meaning of the word "xyz" only if it already knows the meaning of every word used in the definition of xyz. You are asked to write a program to find the smallest extendable subdictionary for a given dictionary.

Input

The input consists of multiple test cases. The first line of each test case contains (1 \le n \le 100), the number of words in the dictionary. Each of the next lines contains a word and its definition, which has at most words. Words are separated by spaces, consist of uppercase English letters, and are at most characters long.

Output

For each test case, print on the first line the number of words in the subdictionary. On the second line, output the list of these words, sorted alphabetically and separated by spaces.

Examples

Example 1

Loading
Loading