The Royal Canadian Mint has commissioned a new line of designer coffee tables whose legs are built from stacks of coins. Every table has four legs. Each leg is a stack of coins of a single coin type, and the four legs must each use a different coin type. All four legs must have exactly the same length.
Many coin types are available, including foreign and commemorative coins, and each coin type has its own thickness. A leg built from a coin of thickness $d$ using $k$ coins has length $k \cdot d$, where $k \ge 1$ is a whole number of coins.
Call a length $L$ constructible when at least four different coin types have a thickness that divides $L$: then each of those four legs can be a whole number of coins of its own type, and all four legs reach the same length $L$.
Given the available coin types and a desired table height, report the two constructible leg lengths nearest to the desired height — the greatest constructible length that does not exceed it, and the smallest constructible length that is not below it.
The input contains several test cases. Each test case begins with a line holding two integers $n$ and $t$ ($4 \le n \le 50$, $1 \le t \le 10$): the number of available coin types and the number of tables to design.
The next $n$ lines each contain one integer — the thickness of a coin type, given in hundredths of a millimetre. Two different coin types may share the same thickness.
The following $t$ lines each contain one integer — the desired height of a table, also in hundredths of a millimetre. Each desired height is at least the smallest constructible length, so both requested values always exist.
A line containing 0 0 follows the last test case and is not processed.
For each desired table height, in the order given, print one line with two integers separated by a single space: the greatest constructible leg length that does not exceed the desired height, followed by the smallest constructible leg length that is not less than the desired height.