The Everbinding War finally ended after the Battle of Wellacotia. The Collean Government, realizing the futility of continuing the war, shortly surrendered afterwards. As such, the agreement signed to end the conflict is to be known as the Wellacotia Treaty. The Wellacotia Treaty consists of terms, with each one being applied to exactly one of the countries. The th term of the treaty is applied to country , where each country is represented by an integer between and . However, before the signing of the treaty, each of the diplomats at the conference decided to reorder a segment of the terms of the treaty. In particular, the th diplomat would choose the segment , such that terms applying to their first favourite country come first, terms applying to their second favourite country would follow, and so on. The list of preferences of the th diplomat is , where is their th favourite country.
The Quatryian government believes that Wellacotia has altered the terms on their copy of the treaty. They know the order of the original terms on the treaty, as well as the changes made by each diplomat. Help them determine the final order of the terms of the Wellacotia Treaty. Since this might be a little too difficult, they instead ask you to determine the country that each term of the treaty applies to.
Constraints
In all subtasks,
is a permutation of .
Subtask 1 [5%]
Subtask 2 [20%]
Subtask 3 [25%]
Subtask 4 [50%]
No additional constraints.
Input Specification
The first line contains three integers, , and .
The second line contains integers, .
For each of the updates, two lines are given. On the th update, the first line contains and , while the second line contains the integers , the list of the th diplomat's favourite countries.
Output Specification
Output one line consisting of integers, the th integer being the country to which the th term of the treaty is applied to.
Sample Input
5 2 3
1 2 3 1 3
1 3
1 3 2
2 4
2 3 1
Sample Output
1 2 3 1 3
Comments