#C139. Undefined Words Finder

    ID: 43488 Type: Default 1000ms 256MiB

Undefined Words Finder

Undefined Words Finder

In this problem, you are given one or more test cases. For each test case, the input begins with an integer (m) representing the number of defined words. This is followed by (m) strings, each denoting a defined word, and finally a sentence containing words separated by spaces. Your task is to output the words in the sentence that are not present in the set of defined words, preserving their order and separating them with a single space. If all words in the sentence are defined, output an empty string.

More formally, let the test sentence be a sequence of words (w_1, w_2, \ldots, w_k) and let (D) be the set of defined words. Then the result is the sequence of words (w_i) such that (w_i \notin D), concatenated by a space. Make sure to process each test case independently. Input is read from standard input and output is written to standard output.

inputFormat

The input is read from standard input and has the following format:

The first line contains an integer (T), the number of test cases.

For each test case:

  • The first line contains an integer (m) ((0 \le m \le k)), the number of defined words.
  • The next (m) lines each contain a defined word.
  • The following line contains a sentence (a string) where words are separated by spaces.

For example:

2 3 code definition test This is a code test 2 python java java is a programming language

outputFormat

For each test case, output a line containing the undefined words (i.e. those not in the defined words list) from the sentence, separated by a single space. If every word is defined, output an empty line.## sample

1
3
code
definition
test
This is a code test
This is a