Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

3108.   Common item
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 3678   Accepted Runs: 1348


Given two array of integers, the task is: find all the integers appears in both of the two arrays and output them is increasing order.


The first line is a single integer n, the test case number. n test cases follows. Each test cases is made up of three lines. In the first line there are two integers m1 and m2 indicating the number of intergers in the two array. The second line contain m1 integers in the first array. The third line contain m2 integers in the second array. Note that All numbers in the input is smaller than 1000.


For each test cases, there is only one line of output, containing the common items of the two array in increasing order, separate two adjacent numbers by a single space and No tailing spaces. If no common items exists, output a blank line.

Sample input

6 5
3 6 5 3 9 2
3 5 3 2 4

3 3
9 9 9
9 9 9

Sample output

2 3 5

Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.3.0
Maintance:G.D.Retop. Developer: SuperHacker, G.D.Retop