#P8838. [传智杯 #3 决赛] 面试

[传智杯 #3 决赛] 面试

Background

disangan233 and disangan333 went to an interview. The interviewer gave them a problem. Can you, as a helpful person, assist them?

Problem Description

There are nn servers. Server ii can process data of size at most aia_i.

Next, there will be kk commands bkb_k. Command ii means sending data of size bib_i, and you need to assign an idle server to it.

Please compute a sequence pkp_k indicating that the data of command ii is assigned to server pip_i, and pkp_k is lexicographically smallest. If it is impossible to assign, output "-1".

For all testdata, n,k6n, k \leq 6, ai,bi10a_i, b_i \leq 10.

Input Format

The input consists of 33 lines.

Line 11 contains two positive integers n,kn, k.

Line 22 contains nn positive integers aia_i, where aia_i indicates the maximum data size that server ii can process.

Line 33 contains kk positive integers bib_i, where bib_i indicates command ii.

Output Format

Output one line containing kk positive integers p1pkp_1 \ldots p_k, or output "-1".

6 6
1 9 1 9 8 1
1 1 4 5 1 4
1 3 2 4 6 5

Hint

Sample Explanation

Command 11 is assigned to server 11.
Command 22 is assigned to server 33.
Command 33 is assigned to server 22.
Command 44 is assigned to server 44.
Command 55 is assigned to server 66.
Command 66 is assigned to server 55.

Translated by ChatGPT 5