Codeforces Round 252 (Div. 2)
C
Valera and Tubes
Codeforces
1500
原题
← BD →
翻译中…

Valera has got a rectangle table consisting of $*n*$ rows and $*m*$ columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row $*x*$ and column $*y*$ by a pair of integers $(*x*, *y*)$.

翻译中…

Valera wants to place exactly $*k*$ tubes on his rectangle table. A tube is such sequence of table cells $(*x*_{1}, *y*_{1})$, $(*x*_{2}, *y*_{2})$, $...$, $(*x*_{*r*}, *y*_{*r*})$, that:

翻译中…
  • $*r* ≥ 2$;
  • for any integer $*i*$ $(1 ≤ *i* ≤ *r* - 1)$ the following equation $|*x*_{*i*} - *x*_{*i* + 1}| + |*y*_{*i*} - *y*_{*i* + 1}| = 1$ holds;
  • each table cell, which belongs to the tube, must occur exactly once in the sequence.
翻译中…

Valera thinks that the tubes are arranged in a fancy manner if the following conditions are fulfilled:

翻译中…
  • no pair of tubes has common cells;
  • each cell of the table belongs to some tube.
翻译中…

Help Valera to arrange $*k*$ tubes on his rectangle table in a fancy manner.

翻译中…

Input

翻译中…

The first line contains three space-separated integers $*n*, *m*, *k*$ ($2 ≤ *n*, *m* ≤ 300$; $2 ≤ 2*k* ≤ *n*·*m*$) — the number of rows, the number of columns and the number of tubes, correspondingly.

翻译中…

Output

翻译中…

Print $*k*$ lines. In the $*i*$-th line print the description of the $*i*$-th tube: first print integer $*r*_{*i*}$ (the number of tube cells), then print $2*r*_{*i*}$ integers $*x*_{*i*1}, *y*_{*i*1}, *x*_{*i*2}, *y*_{*i*2}, ..., *x*_{*ir*_{*i*}}, *y*_{*ir*_{*i*}}$ (the sequence of table cells).

翻译中…

If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists.

翻译中…

Note

翻译中…

Picture for the first sample:

翻译中…

image

翻译中…

Picture for the second sample:

翻译中…

image

翻译中…

样例

Input #1
3 3 3
Output #1
3 1 1 1 2 1 3
3 2 1 2 2 2 3
3 3 1 3 2 3 3
InputCopy OutputCopy
Input #2
2 3 1
Output #2
6 1 1 1 2 1 3 2 3 2 2 2 1
InputCopy OutputCopy
题目信息
题号
441C
时间限制
1 s
内存限制
256 MB
标签
构造
DFS 及类似
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。