#K11216. Union of Book IDs Using Keywords

    ID: 23420 Type: Default 1000ms 256MiB

Union of Book IDs Using Keywords

Union of Book IDs Using Keywords

You are given a list of keywords, each associated with a list of book IDs. Given two keywords, your task is to find the union of the book IDs corresponding to these keywords and output them in ascending order.

Formally, if ( A ) and ( B ) are the sets of book IDs for keywordA and keywordB respectively, you are to compute ( A \cup B = {x \mid x \in A \text{ or } x \in B}).

If a keyword is not present, treat its list as empty.

inputFormat

The first line contains an integer ( K ), the number of keywords. The next ( K ) lines each contain a keyword followed by an integer ( N ) denoting the number of book IDs, and then ( N ) integers representing the book IDs. The last line contains two strings: keywordA and keywordB.

outputFormat

Output the union of the book IDs for the two specified keywords in ascending order. The book IDs should be separated by a single space. If no book IDs exist, output an empty line.## sample

3
a 4 1 2 3 4
b 4 3 4 5 6
c 4 5 6 7 8
a c
1 2 3 4 5 6 7 8