Question #43076

You will get several big numbers.

You have to sort these numbers in decreasing order.

Input

The first line is an integer N (1≤N≤10000) means the number of big numbers.

In the following lines, each line is a big number with K digits (1≤K≤50).

Then the line after the big numbers is an integer M (5≤M≤10) means the number of queries.

In the following lines, each line is an integer Q (1≤Q≤N) means you need to print out the Q-th big number.

Output

There must have M lines.

Each line is a big number according to each query Q.

Sample Input

5

362563562

936215450250525

156164546213651615

936215450228602

125345963

5

1

2

3

4

5

Sample Output

156164546213651615

936215450250525

936215450228602

362563562

125345963

You have to sort these numbers in decreasing order.

Input

The first line is an integer N (1≤N≤10000) means the number of big numbers.

In the following lines, each line is a big number with K digits (1≤K≤50).

Then the line after the big numbers is an integer M (5≤M≤10) means the number of queries.

In the following lines, each line is an integer Q (1≤Q≤N) means you need to print out the Q-th big number.

Output

There must have M lines.

Each line is a big number according to each query Q.

Sample Input

5

362563562

936215450250525

156164546213651615

936215450228602

125345963

5

1

2

3

4

5

Sample Output

156164546213651615

936215450250525

936215450228602

362563562

125345963

Expert's answer

Learn more about our help with Assignments: C++

## Comments

## Leave a comment