SP17945 MMMAGIC5 - Mickey Mouse Magic Trick v5

Description

![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP17945/b9498402e7243d303a91566137d3d2a502abdc07.png)

Input Format

All integers in the same line are single-space separated (the same concerns problem output). Values n, k are constant. In this problem n=124 and k=5. There are also problems with different values: [MMMAGIC3](../../problems/MMMAGIC3/), [MMMAGIC4](../../problems/MMMAGIC4/), [MMMAGIC6](../../problems/MMMAGIC6/) The first line of input contains two integers M, D, where M is the number of test cases in which Mickey needs help, D is the number of test cases in which Donald needs help (M+D < 10 $ ^{6} $ ). Every of next M lines contains k distinct integers from range \[1, n\] - the values on cards given to Mickey. The values are sorted in ascending order. Every of next D lines contains k-1 distinct integers from range \[1, n\] - the cards left to Donald on the table. The order is the same, as on the table, from left to right.

Output Format

For each Mickey's query write a line with k-1 integers - the values on the cards, that Mickey have to leave on the table, from left to right. For each Donald's query write a line with one integer - the value of hidden card or (if in Your strategy such situation is impossible) any of remaining values.