Ave and Number Recognition

5

1 votes
Medium
Problem

Today Ave is learning number matching. Basically, what happens is that Alice gives Ave n random numbers and tells him to store these numbers. But that is not the only task Alice had given to Ave. Now Alice gives Ave some special numbers and tells Bob to return those numbers in his database which have prefix matching to the special numbers. Remember if there exists a number which is equal to the special number, Ave should not return it(See example to be more clear about it). Can you write this program, so that Ave has one more ability in his arsenal.

Input:

First line contains the number of random numbers, n

Second line would contain n space separated integers A1, A2, ..., An.

Third line would contain number k, the number of special numbers.

Next k lines would contain integers B1, B2, ..., Bk denoting the special numbers.

Output:

Print k lines. In each line, there should be space separated numbers denoting the numbers matched with the special number. If there are no such numbers for the Bi. print "No match".

Please note that numbers should be printed in lexicographical order.

Constraints:

1 ≤ n ≤ 104

1 ≤ Ai ≤ 1020

1 ≤ k ≤ 104

1 ≤ Bi ≤ 1020

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the second example, 2133 is printed before 215 because 2133 is lexicographically smaller than 215.

Editor Image

?