#icpc2014springg. [icpc2014spring_g]Proportional Representation

[icpc2014spring_g]Proportional Representation

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

An election selecting the members of the parliament in JAG Kingdom was held. The only system adopted in this country is the party-list proportional representation. In this system, each citizen votes for a political party, and the number of seats a party wins will be proportional to the number of votes it receives. Since the total number of seats in the parliament is an integer, of course, it is often impossible to allocate seats exactly proportionaly. In JAG Kingdom, the following method, known as the D'Hondt method, is used to determine the number of seats for each party.

Assume that every party has an unlimited supply of candidates and the candidates of each party are ordered in some way. To the yy-th candidate of a party which received xx votes, assign the value dfracxy\\dfrac{x}{y}. Then all the candidates are sorted in the decreasing order of their assigned values. The first TT candidates are considered to win, where TT is the total number of seats, and the number of seats a party win is the number of its winning candidates.

The table below shows an example with three parties. The first party received 4040 votes, the second 6060 votes, and the third 3030 votes. If the total number of seats is T=9T = 9, the first party will win 33 seats, the second 44 seats, and the third 22 seats.

When selecting winning candidates, ties are broken by lottery; any tied candidates will have a chance to win. For instance, in the example above, if T=5T = 5 then two candidates tie for the value 2020 and there are two possible outcomes:

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

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

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

Given NN, MM, and S_iS\_i (1leileM1 \\le i \\le M), denoting the total number of valid votes, the number of parties, and the number of seats the ii-th party won, respectively, your task is to determine for each party the minimum and the maximum possible number of votes it received. Note that for some cases there might be no such situation with the given NN, MM, and S_iS\_i.


Input

The first line of the input contains two integers NN (1leNle1091 \\le N \\le 10^9) and MM (1leMle30,0001 \\le M \\le 30{,}000), where NN is the total number of valid votes and MM is the number of parties. MM lines follow, the ii-th of which contains a single integer S_iS\_i (0leS_ile30,0000 \\le S\_i \\le 30{,}000), representing the number of seats the ii-th party won. You can assume that there exists ii with S_ine0S\_i \\ne 0.

Output

If there is no situation with the given NN, MM, and S_iS\_i, display the word "impossible". Otherwise, output MM lines, each containing two integers. The first integer and the second integer in the ii-th line should be the minimum and the maximum possible number of votes the ii-th party received, respectively.


Sample Input 1

10 2
2
1```

### Output for the Sample Input 1

```plain
5 7
3 5```

* * *

### Sample Input 2

```plain
5 6
0
2
0
2
6
0```

### Output for the Sample Input 2

```plain
0 0
1 1
0 0
1 1
3 3
0 0```

* * *

### Sample Input 3

```plain
2000 5
200
201
202
203
204```

### Output for the Sample Input 3

```plain
396 397
397 399
399 401
401 403
403 404```

* * *

### Sample Input 4

```plain
15 10
1
1
1
1
1
1
1
1
1
13```

### Output for the Sample Input 4

```plain
impossible```

* * *

### Sample Input 5

```plain
1000000000 9
12507
16653
26746
21516
29090
10215
28375
21379
18494```

### Output for the Sample Input 5

```plain
67611619 67619582
90024490 90033301
144586260 144597136
116313392 116323198
157257695 157269050
55221291 55228786
153392475 153403684
115572783 115582561
99976756 99985943```

* * *

### Source Name

[Japan Alumni Group Spring Contest 2014](http://acm-icpc.aitea.net/index.php?2013%2FPractice%2F%BD%D5%A5%B3%A5%F3%A5%C6%A5%B9%A5%C8%2F%B0%C6%C6%E2)

* * *