#include<bits/stdc++.h>
#define MAXN 2007
#define MAXK 1000007
using namespace std;

struct carpet{
    int a,b,c,d;
}carp[MAXK];

int n,m,k;
int cover[MAXN][MAXN],pref[MAXN][MAXN];
vector< pair<int,int> > ans[MAXK];

int sum(int from,int to,int l,int r){
    return pref[to][r] - pref[to][l-1] - pref[from-1][r] + pref[from-1][l-1];
}

int firstrow(int from,int to,int l,int r){
    int lt = from-1, rt = to+1,tt;

    while(lt+1<rt){
        tt=(lt+rt)/2;

        if(sum(from,tt,l,r) > 0){
            rt=tt;
        }else{
            lt=tt;
        }
    }

    return rt;
}

int firstcol(int row,int l,int r){
    int lt = l-1, rt = r+1,tt;

    while(lt+1<rt){
        tt=(lt+rt)/2;

        if(sum(row,row,l,tt) > 0){
            rt=tt;
        }else{
            lt=tt;
        }
    }

    return rt;
}

int main(){

    cin>>n>>m>>k;

    for(int i=1;i<=k;i++){

        int a,b,c,d;
        cin>>a>>b>>c>>d;

        carp[i]={a,b,c,d};

        cover[a][c]++;
        cover[a][d+1]--;
        cover[b+1][c]--;
        cover[b+1][d+1]++;
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            cover[i][f]+=cover[i-1][f] + cover[i][f-1] - cover[i-1][f-1];

            pref[i][f] = (cover[i][f]==1) ? 1 : 0;
            pref[i][f] += pref[i-1][f] + pref[i][f-1] - pref[i-1][f-1];
        }
    }

    for(int i=1;i<=k;i++){

        int row = carp[i].a-1, col = carp[i].c;
        int l = carp[i].c, r = carp[i].d;

        while(true){
            row = firstrow(row+1,carp[i].b,l,r);
            
            if(row == carp[i].b+1)break;

            col=l-1;
            while(true){
                col = firstcol(row,col+1,r);
                if(col==r+1)break;

                ans[i].push_back({row,col});
            }
        }

        cout<<ans[i].size()<<" : ";
        for(auto s:ans[i]){
            cout<<"("<<s.first<<","<<s.second<<") ";
        }
        cout<<"\n";
    }

    return 0;
}