XXL Olympic Football

Time limit: 0.15s Memory limit: 512MB Input: Output:

To make the 2028 Summer Olympics even more exciting, the organizers have planned an XXL football match for both the opening and closing ceremonies. A special 1000×4001000\times 400 meter field is already in construction for these games!

here are 2M2M athletes participating, coming from NN countries. Specifically, AiA_i athletes are representing country ii for each ii from 00 to N1N - 1, inclusive. For the two football games we have the following restrictions:

  • For the opening ceremony, two teams of KK athletes each must be formed.
  • For the closing ceremony, two teams of MKM-K athletes each must be formed.
  • Every athlete must participate in exactly one game (either opening or closing), and in only one team.
  • No two athletes from the same country may play against each other in a game.

As the chief computer scientist of the Olympics, your task is to divide the athletes into four teams (two per game) satisfying all the above conditions.

You can assume that:

  • K12MK \ge \frac{1}{2}M, that is, the opening is at least as popular as the closing ceremony.
  • K23MK \le \frac{2}{3}M, that is, the opening may be just slightly more popular than the closing ceremony.
  • No country sends more than MM athletes.

We can prove that a valid assignment always exists under the given conditions.

Input data

The first line contains two integers NN and KK - the numbers of countries, and the number of athletes to play in a team in the opening ceremony, respectively.

The second line contains NN positive integers A0,A1,,AN1A_0, A_1, \ldots, A_{N-1}, the number of athletes from each country.

Output data

Print NN lines. Line ii should contain the assignment of the athletes from country ii, represented by four non-negative integers:

  • The number of athletes assigned to the home team of the opening ceremony.
  • The number of athletes assigned to the away team of the opening ceremony.
  • The number of athletes assigned to the home team of the closing ceremony.
  • The number of athletes assigned to the away team of the closing ceremony.

If there are multiple valid solutions, you may output any of them.

Constraints and clarifications

  • 2N1000002 \le N \le 100\,000.
  • i=0N1Ai\sum_{i=0}^{N-1} A_i is even. Let M=12i=0N1AiM = \frac{1}{2}\sum_{i=0}^{N-1} A_i.
  • 1Aimin(M,109)1\leq A_i \leq \min\Bigl(M, 10^9\Bigr) for each i=0N1i=0 \ldots N-1.
  • 12MK23M\frac{1}{2}M \le K \le \frac{2}{3}M.
# Score Restrictions
0 0 Examples
1 10 N3N \le 3.
2 10 N8N \le 8.
3 20 MM is even and K=12MK=\frac{1}{2}M.
4 20 MM is divisible by 33 and K=23MK=\frac{2}{3}M.
5 40 No additional limitations.

Example 1

stdin

3 4
5 3 6

stdout

4 0 1 0
0 0 0 3
0 4 2 0

Explanation

In the first sample case one valid assignment is:

  • 44 athletes from country 11 play against 44 athletes from country 33 in the opening ceremony.
  • All 33 athletes from country 22 play against the remaining athletes from countries 11 and 33 in the closing ceremony.
    Note that there exist other valid assignments.

Example 2

stdin

5 6
3 4 3 6 4

stdout

2 0 0 1
0 4 0 0
0 2 0 1
4 0 0 2
0 0 4 0

Log in or sign up to be able to send submissions!