## Word Counting

View as PDF

Points: 10
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem type

One of Oliver's chores is organizing his bookshelf. In order to do so, he needs to know how many words are in each of his books. Oliver's friend, Colin, has a massive brain, so he knows that the -th book contains words. Unfortunately, Colin is a troll and decides not to tell Oliver the number of words in the books.

Instead, Colin got his hands on magic buttons. The -th of these buttons converts a book into pages, with an equal number of words on each page (note that the number of words on the page does not need to be an integer). Colin will use one of the magic buttons on each of the books (note that the same button can be used on multiple different books). Once Colin has done this, Oliver will figure out the number of words in each book. Oliver does this by counting the number of words on the first page, then counting the number of pages in the book and multiplying the two numbers together. Oliver takes one unit of time to count each word and one unit of time to count each page.

Because Colin isn't that big of a troll, he decides to use the buttons that minimize the amount of time Oliver will spend counting. Can you tell Colin what button he should use for each book?

#### Input Specification

The first line will contain two integers and .

The next line will contain integers. The -th integer will be .

The next line will contain integers. The -th integer will be .

#### Output Specification

Print space separated integers. The -th of these integers should contain the index of the button that Colin should use for the -th book to minimize Oliver's counting time. If there are multiple indices that minimize the time, print the smallest one.

#### Sample Input

5 4
2 4 5 1 8
8 1 20 1000000000

#### Sample Output

1 4 2 5

#### Sample Explanation

The first and second buttons both result in the minimum counting time for the first book, but the button with index one is used because it has the smaller index of the two. When button one is used, the number of pages is 2 and the number of words per page is 8 / 2 = 4, resulting in a counting time of 4 + 2 = 6.

## Comments

There are no comments at the moment.