Problem Postmortem
At the AUCPL inc problemsetting department, it is customary for a postmortem to be held monthly, where all unclear statements, typos, and broken test cases from the previous month are reviewed and reflected on. Before each issue can be presented, its memo needs to be reviewed by exactly one department VP to ensure it isn't incorrect or too embarrassing.
The department has VPs, with IDs
through
. Each VP is also assigned a clearance tier, which is a positive integer. Each postmortem memo additionally has a severity score
. Each memo can only be reviewed by a VP whose clearance tier divides
exactly (no remainder). If multiple VPs are eligible, the memo goes to the one with the highest clearance tier. If there is still a tie (i.e. multiple VPs have the same clearance tier), the one with the smallest ID is chosen.
Given a list of memos, each with severity score
, determine which department VP should review each memo in time for the postmortem meeting.
Input
The first line contains two integers and
(
) - the number of department VPs and the number of postmortem memos.
The second line contains integers
(
), the clearance tier of each department VP.
The next line contains integers
(
), the severity score of each postmortem memo.
Output
For each memo, print a single integer - the ID number of the department VP who reviews it. It is guaranteed that for each memo, at least one VP has a clearance tier that divides .
Example
Input 1
4 3
6 3 6 2
6 3 10
Output 1
1
2
4
For the first memo, all of the VPs have clearance tiers that divide the severity score . There are also multiple VPs with the highest such score,
, so the one with the smallest ID is picked.
For the second and third memos, only a single VP has an eligible clearance tier.
Input 2
5 4
4 2 8 1 8
8 4 7 1
Output 2
3
1
4
4
Input 3
6 5
3 5 15 5 9 1
15 9 5 30 1
Output 3
3
5
2
3
6
Comments