#P1666E. Even Split

    ID: 1230 Type: RemoteJudge 3000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>binary searchconstructive algorithmsgreedymath*2500

Even Split

Description

A revolution has recently happened in Segmentland. The new government is committed to equality, and they hired you to help with land redistribution in the country.

Segmentland is a segment of length ll kilometers, with the capital in one of its ends. There are nn citizens in Segmentland, the home of ii-th citizen is located at the point aia_i kilometers from the capital. No two homes are located at the same point. Each citizen should receive a segment of positive length with ends at integer distances from the capital that contains her home. The union of these segments should be the whole of Segmentland, and they should not have common points besides their ends. To ensure equality, the difference between the lengths of the longest and the shortest segments should be as small as possible.

The first line of the input contains two integers ll and nn (2l109;1n1052 \leq l \leq 10^9; 1 \leq n \leq 10^5).

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (0<a1<a2<<an<l0 < a_1 < a_2 < \dots < a_n < l).

Output nn pairs of numbers si,fis_i, f_i (0si<fil0 \leq s_i < f_i \leq l), one pair per line. The pair on ii-th line denotes the ends of the [si,fi][s_i, f_i] segment that ii-th citizen receives.

If there are many possible arrangements with the same difference between the lengths of the longest and the shortest segments, you can output any of them.

Input

The first line of the input contains two integers ll and nn (2l109;1n1052 \leq l \leq 10^9; 1 \leq n \leq 10^5).

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (0<a1<a2<<an<l0 < a_1 < a_2 < \dots < a_n < l).

Output

Output nn pairs of numbers si,fis_i, f_i (0si<fil0 \leq s_i < f_i \leq l), one pair per line. The pair on ii-th line denotes the ends of the [si,fi][s_i, f_i] segment that ii-th citizen receives.

If there are many possible arrangements with the same difference between the lengths of the longest and the shortest segments, you can output any of them.

Sample Input 1

6 3
1 3 5

Sample Output 1

0 2
2 4
4 6

Sample Input 2

10 2
1 2

Sample Output 2

0 2
2 10

Note

In the first example, it is possible to make all segments equal. Viva la revolucion!

In the second example, citizens live close to the capital, so the length of the shortest segment is 2 and the length of the longest segment is 8.