Heritage of the king#5109

Heritage of the king

1 second
122.174 megabytes
Very easy

A wise king ruled a distant rectangular country. He had sons. Before his death, he bequeathed the territory of his country to his sons. The king decided, based on each son's wisdom, to allocate a certain area of land to each.

The entire country is a rectangle with dimensions n \times m kilometers, divided into 1 \times 1 kilometer square regions. Each son can inherit only a whole number of these regions. Furthermore, every son wants to receive a connected territory: from any cell of a son's land, it must be possible to reach any other cell of his land by moving only through adjacent cells belonging to him (two regions are considered adjacent if they share a common side).

Help the sons divide the country according to the king's will.

Input

The first line contains three positive integers , , and (1 \le n, m \le 700, 1 \le k \le 10000) — the country's dimensions and the number of sons.

The second line contains positive integers a_1, a_2, \ldots, a_k, where a_i is the area (number of 1 \times 1 regions) bequeathed to the -th son. It is guaranteed that a_1 + a_2 + \cdots + a_k = n \times m.

Output

Print lines, each containing numbers. The number in the -th row and -th column should specify the index of the son ( to ) who inherits that region.

Examples

Example 1

Loading
Loading