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?≤?2k?≤?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 ri (the number of tube cells), then print 2ri integersxi1,?yi1,?xi2,?yi2,?...,?xiri,?yiri (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.
Sample test(s) input 3 3 3
output 3 1 1 1 2 1 3
3 2 1 2 2 2 3
3 3 1 3 2 3 3
input 2 3 1
output 6 1 1 1 2 1 3 2 3 2 2 2 1
Note Picture for the first sample:
Picture fZ??http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vciB0aGUgc2Vjb25kIHNhbXBsZTo8L3A+CjxjZW50ZXI+PGltZyBjbGFzcz0="tex-graphics" src="https://www.cppentry.com/upload_files/article/49/1_hqoa3__.png" alt="\"> 解题报告 让每个人两个,剩下给第一个
#include
#include
#include
using namespace std; int mmap[310][310]; int main() { int n,m,k; while(cin>>n>>m>>k) { int t=n*m-(k-1)*2; int x=1,y=1; printf("%d",t); while(t--) { printf(" %d %d",x,y); mmap[x][y]=1; if(y+1<=m&&!mmap[x][y+1]) { y++; } else if(y-1>=1&&!mmap[x][y-1]) y--; else x++; } k--; while(k--) { printf("\n2"); t=2; while(t--) { printf(" %d %d",x,y); mmap[x][y]=1; if(y+1<=m&&!mmap[x][y+1]) { y++; } else if(y-1>=1&&!mmap[x][y-1]) y--; else x++; } } printf("\n"); } }