Tim has discovered that, at a certain point in the future, medieval artifacts — especially the weapons and armor of the era's armies — become extremely valuable. He plans to travel back to the Middle Ages, gather items such as chainmail and lances, and later sell them for a fortune.
The catch is that he has no currency the locals will accept, so he must obtain everything he needs by bartering. Before he starts trading, Tim wants to know the fewest trades each item will cost him, so he can focus first on the items that take the fewest trades.
His time machine can hold at most 5 items at once, and Tim will never make a trade that leaves him holding more than 5 items.
The first line contains the number of data sets $K$. Each data set has the following form.
The first line contains four integers $M$, $H$, $W$, and $T$:
The next line contains $H$ words: the names of the items Tim has. The following line contains $W$ words: the names of the items Tim wants.
Then the $T$ trades follow, each described by two lines. The first line of a trade contains an integer $1 \le g \le 5$ followed by the names of the $g$ items Tim gives away. The second line contains an integer $1 \le a \le 5$ followed by the names of the $a$ items Tim receives.
To perform a trade, Tim must currently hold every item it requires him to give away, and after the trade the total number of items he holds must not exceed 5.
For each data set, print a line Data Set x:, where $x$ is the data set's number (starting from 1). On the next line, print the fewest number of trades Tim needs to obtain every wanted item using at most $M$ trades, or Impossible. if that cannot be done. Separate consecutive data sets with a blank line.