Mint#1181

Mint

2 seconds
128 megabytes
Very easy

The Royal Canadian Mint has commissioned a series of coffee tables, where each table has legs constructed from stacks of coins. Each table has four legs, and in each leg, coins of the same denomination are used, but all four legs must have coins of different denominations. For example, one leg may consist of 25 cent coins, another of one cent coins, and another of two cent coins. All legs must be the same height.

Many coins are available, including commemorative and foreign coins. Given the available coin denominations and the desired table height, determine, for each table, the largest possible leg height not exceeding the desired height, and the smallest possible leg height not less than the desired height. Each leg must be made from a unique coin denomination.

Input

Consists of several test cases. Each test case begins with two integers: (4 \leq n \leq 100), the number of available coin denominations, and (1 \leq t \leq 10), the number of tables to be made. Then follow lines, each giving the thickness of a coin in hundredths of a millimetre. Next, lines follow, each specifying the desired table height (also in hundredths of a millimetre). The last line contains and marks the end of the input.

Output

For each table, print two integers: the largest leg height not exceeding the desired table height, and the smallest leg height not less than the desired table height.

Examples

Example 1

Loading
Loading