cho.sh
Notes
Loading...

Chip Construction

Time limit

1s

Memory limit

128 MB

Problem

There are N components on a board, numbered 1 through N from left to right. Each component has a nonnegative integer priority.

Only K power lines are available. One power line may be connected directly to one component, and it may also be shared with one other component. Thus, one power line can serve at most two components.

Wires placed on the top of the board must not cross each other. A wire may, however, be placed inside the interval enclosed by another wire.

The chip's importance is computed as follows.

  1. If a power line is connected to exactly one component, add the square of that component's priority.
  2. If a power line is connected to two components, add the product of the two priorities.

Output a valid connection whose chip importance is as large as possible.

Input

The first line contains two integers N (1 <= N <= 50) and K (1 <= K <= 20).

The second line contains N integers. The i-th integer is the priority of component i, and every priority is between 0 and 1,000 inclusive.

Output

For the first K lines, output the component number directly connected to each power line. Output 0 for an unused power line.

For the next N lines, output which component each component shares power with. If a component uses a power line alone, output its own number. If a component does not use power, output 0. If two components share the same power line, they must output each other's numbers.

You may output any valid configuration that maximizes the chip's importance.