#P2902. [USACO08MAR] Pearl Pairing G

[USACO08MAR] Pearl Pairing G

Description

At Bessie's recent birthday party, she received N(2N105,N0(mod2))N(2 \le N \le 10^5,N\equiv0\pmod{2}) pearls, each painted one of C different colors (1CN1\le C \le N).

Upon observing that the number of pearls NN is always even, her creative juices flowed and she decided to pair the pearls so that each pair of pearls has two different colors.

Knowing that such a set of pairings is always possible for the supplied testcases, help Bessie perform such a pairing. If there are multiple ways of creating a pairing, any solution suffices.

Input Format

Line 11: Two space-separated integers: NN and CC.

Lines 2C+12 \ldots C+1: Line i+1i+1 tells the count of pearls with color ii: CiC_i.

Output Format

Lines 1N21\ldots \dfrac{N}{2}: Line ii contains two integers aia_i and bib_i indicating that Bessie can pair two pearls with respective colors aia_i and bib_i.

8 3 
2 
2 
4 

1 3 
1 3 
2 3 
3 2 

Hint

There are 88 pearls and 33 different colors. Two pearls have color I\mathrm{I}; two have color II\mathrm{II}; four have color III\mathrm{III}.

Bessie pairs each pearl of color III\mathrm{III} with one of color I\mathrm{I} and Ii\mathrm{Ii}.