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*<sub class="lower-index">1</sub>, *y*<sub class="lower-index">1</sub>), (*x*<sub class="lower-index">2</sub>, *y*<sub class="lower-index">2</sub>), ..., (*x*<sub class="lower-index">*r*</sub>, *y*<sub class="lower-index">*r*</sub>), that: 
 -  *r* ≥ 2; -  for any integer *i* (1 ≤ *i* ≤ *r* - 1) the following equation |*x*<sub class="lower-index">*i*</sub> - *x*<sub class="lower-index">*i* + 1</sub>| + |*y*<sub class="lower-index">*i*</sub> - *y*<sub class="lower-index">*i* + 1</sub>| = 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.
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.
#include<stdio.h>
#include<stdlib.h>

struct celula{
        int numeroCano;
        int numeroCelula;
    };

int main(int* args[]){
    int numeroLinhas, numeroColunas, numeroCanos;

    scanf("%d %d %d", &numeroLinhas, &numeroColunas, &numeroCanos);

    struct celula mesa[numeroLinhas][numeroColunas];
    int tamCanos[numeroCanos];

    int i;
    for(i = 0; i < numeroCanos; i++){
        if(i < (numeroCanos-1)){
            tamCanos[i] = 2;
        }
        else{
           tamCanos[i] = numeroLinhas*numeroColunas -(numeroCanos-1)*2;
        }
    }

    int linha;
    int coluna;

    int n_cano = 0;
    int tam = 0;

    int canos[numeroCanos][tamCanos[numeroCanos-1]*2];

    for(linha = 0; linha < numeroLinhas; linha++){
        if(linha%2 == 0){
            for(coluna = 0; coluna < numeroColunas; coluna++){
                struct celula cel;
                tam++;
                cel.numeroCano = n_cano;
                cel.numeroCelula = tam;
                mesa[linha][coluna] = cel;

                canos[n_cano][2*(tam-1)] = linha;
                canos[n_cano][2*(tam-1) + 1] = coluna;

                if(n_cano < (numeroCanos-1)){
                    if(tam == 2){
                        n_cano++;
                        tam = 0;
                    }
                }
            }
        }
        else{
            for(coluna = (numeroColunas-1); coluna >= 0; coluna--){
                struct celula cel;
                tam++;
                cel.numeroCano = n_cano;
                cel.numeroCelula = tam;
                mesa[linha][coluna] = cel;

                canos[n_cano][2*(tam-1)] = linha;
                canos[n_cano][2*(tam-1) + 1] = coluna;

                if(n_cano < (numeroCanos-1)){
                    if(tam == 2){
                        n_cano++;
                        tam = 0;
                    }
                }
            }
        }
    }

    for(n_cano = 0; n_cano < numeroCanos; n_cano++){
        printf("%d", tamCanos[n_cano]);
        for(tam = 0; tam < tamCanos[n_cano]; tam++){
            printf(" %d",canos[n_cano][2*tam]+1);
            printf(" %d",canos[n_cano][2*tam + 1]+1);
        }
        printf("\n");
    }

    return 0;
}
