FIICode 2024 Open | The Best Farm

This was the problem page during the contest. Access the current page here.
Time limit: 1s Memory limit: 256MB Input: Output:

Erniv and Kaimao, the prominent farmers of the Summoner's Rift, often find themselves at odds. In an effort to mend their relationship, King Kong-Wu offers them a piece of land from his kingdom to work on together. This land is a rectangle with a length of ll meters and a width of ww meters. Both Erniv and Kaimao reluctantly agree to work together and decide to divide the land into nn equal sections. They aim to make this division easier by ensuring that each new piece of land remains a rectangle, with side lengths being integers. Can you assist them in finding a suitable way to divide their field?

Input

One line with three integers ll, ww, and nn (1l,w,n5001 \le l, w, n \le 500), representing the length and width of Kong-Wu's field and the number of divisions that Erniv and Kaimao decided to do.

Output

If there is no solution, display impossible. Otherwise, display possible and another ll lines, each containing ww numbers separated with a space between them, describing a possible division of Kong-Wu's field. The number of occurrences of each of the first nn numbers must be equal, and, for each number, its occurrences must form a single rectangular region. If there are multiple solutions, any of them is acceptable.

Example 1

stdin

4 4 4

stdout

possible
1 1 2 2 
1 1 2 2 
3 3 3 3 
4 4 4 4 

Example 2

stdin

100 100 33

stdout

impossible

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