
In the heart of the village of Lungani, New Year's Eve is more than just a celebration, it is a living tradition. Groups of carollers, known as cete, wander through the snowy streets performing ancient rituals like the Cerb (Deer dance), Capra (Goat dance), and the legendary Bear dance.
The village elders say the magic of the ritual only works if the members of a group stay together. This year, the village council decided to organize all performers in the central square, which can be represented as an grid of cells. To preserve the tradition, the members of each group must occupy a single connected area.
Task
You are given three integers , and , and a sequence of integers .
Construct an matrix using values from the set such that:
- For every (), the value appears exactly times in the matrix.
- For every , the set of cells containing the value forms a single connected component under 4-directional adjacency (up, down, left, right).
Input data
The first line contains three integers: (number of rows), (number of columns), and (number of groups).
The second line contains integers: , representing the number of members in each group.
Output data
Print lines, each containing space-separated integers representing the constructed matrix.
Constraints and clarifications
- It is guaranteed that at least one valid solution always exists.
- If multiple valid matrices exist, you may output any of them.
Example
stdin
2 3 3
2 3 1
stdout
1 1 2
3 2 2
Explanation
Value occupies cells and , which are adjacent. Value occupies , and , which form a connected region. Value appears once at .