Macarie has received a new problem as part of his informatics assignment, and here is its statement:
We are given an array with positive integers. Let's consider the increasing array made of all positive divisors, not necessarily distinct of the values from . As an example, for and , we have the array .
Task
Given an array made of positive integers, representing positions from , find for each of the values, the value at the respective position from the array .
Input data
The first line of the input file macarie.in
contains the integers and .
The second line of the input contains positive integers, representing the values from .
The third line has positive integers, representing the values from . The numbers on the same line are separated by singular spaces.
Output data
The first line of the output file macarie.out
contains positive integers, separated by spaces, representing the values from , in order in which the positions show up in .
Constraints and clarifications
- , ;
- The arrays , and are indexed from .
- for . The values from are not necessarily distinct.
- for , wher is the length of .
# | Score | Constraints |
---|---|---|
1 | 23 | All input values are |
2 | 18 | All values are prime numbers |
3 | 23 | , |
4 | 15 | |
5 | 21 | No additional constraints. |
Example 1
macarie.in
4 5
32 42 49 21
2 5 9 7 17
macarie.out
1 2 4 3 21
Explanation
and . and .
Example 2
macarie.in
5 4
24 56 8 490 28
35 25 28 38
macarie.out
70 12 14 490
Explanation
, and , , , .