SP17943 MMMAGIC3 - Mickey Mouse Magic Trick v3

Description

![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP17943/3aa7e179bc80b62279b4f3556a92771923f8e562.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=8 and k=3. There are also problems with different values: [MMMAGIC4](../../problems/MMMAGIC4/), [MMMAGIC5](../../problems/MMMAGIC5/), [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 < 200) . Every of next M lines contains k distinct integers from range \[1, n\] - the values on cards given to Mickey. The order of values is casual. 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.