Proportional Representation

No attempts yetTime limit5sMemory limit128 MB

Problem

JAG Kingdom elected the members of its parliament. The country uses only party-list proportional representation: each citizen votes for one party, and the number of seats a party wins is proportional to the number of votes it receives. The parliament has an integer number of seats, so an exactly proportional split is usually impossible. The kingdom splits the seats with the D'Hondt method.

Every party has an unlimited supply of candidates, and the candidates of a party are ordered. The yy-th candidate of a party that received xx votes gets the value xy\dfrac{x}{y}. All candidates are sorted by value in decreasing order, and the first TT candidates win, where TT is the total number of seats. The number of seats a party wins is the number of its winning candidates.

Take three parties with 4040, 6060 and 3030 votes as an example. With T=9T = 9 seats the first party wins 33 seats, the second wins 44 seats, and the third wins 22 seats.

Ties are broken by lottery, so every tied candidate has a chance to win. In the same example with T=5T = 5, two candidates tie at the value 2020, and both of the following outcomes are possible.

  • The first party wins 22 seats, the second wins 22 seats, and the third wins 11 seat.
  • The first party wins 11 seat, the second wins 33 seats, and the third wins 11 seat.

You have just heard the results of the election on TV. You know the total number of valid votes and the number of seats each party won, and you wonder how many votes each party received.

You are given the total number of valid votes NN, the number of parties MM, and the number of seats SiS_i that party ii won. For each party, determine the minimum and the maximum number of votes it could have received. For some inputs no vote count produces the given seats at all.

Input

The first line contains two integers NN (1N1091 \le N \le 10^9) and MM (1M300001 \le M \le 30000), the total number of valid votes and the number of parties. Each of the next MM lines contains one integer SiS_i (0Si300000 \le S_i \le 30000), the number of seats party ii won. At least one SiS_i is not zero.

Output

If no vote count produces the given NN, MM and SiS_i, print impossible. Otherwise print MM lines. The ii-th line contains two integers, the minimum and the maximum number of votes party ii could have received.