eolymp
bolt
Try our new interface for solving problems
Problems

Heritage of the king

Heritage of the king

In one faraway rectangular country the wise king rules. And he had k sons. Before his death, he bequeathed the territory of his country to his sons. The governor reasoned who among the sons is wiser, and on this basis he will give to each son a certain area of land.

The entire rectangular area of the country has dimensions n × m kilometers and is divided into square regions of size 1 × 1 kilometers. Each son can inherit only a whole number of regions. Also, every son wants to get into the possession the connected part of land (from any cell of his land the son can go to another only along the adjacent cells of his land. The regions are considered to be adjacent if they have a common side).

Help the sons to divide the country according to the will of the king.

Input

First line contains three positive integers n, m and k (1n, m700, 1k10000) - the sizes of the country and number of sons.

Second line contains k positive integers a1, a2, ..., aK, where ai is the area that wise king bequeathed to the i-th son. It is guaranteed that a1 + a2 + ...+ ak = n * m.

Output

Print n lines with m numbers in each. The intersection of line number i and column number j must contain the number of the son whom will be given this region (number from 1 to k).

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
2 3 2
5 1
Output example #1
1 1 1
1 2 1