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

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

int n,m,k;
int cover[MAXN][MAXN];
bitset<MAXM> excl[MAXN];   
bitset<MAXM> col_from[MAXM]; 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    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 c=m; c>=1; c--){
        col_from[c]=col_from[c+1];
        col_from[c].set(c);
    }

    for(int r=1;r<=n;r++)
        for(int c=1;c<=m;c++){
            cover[r][c]+=cover[r-1][c]+cover[r][c-1]-cover[r-1][c-1];
            if(cover[r][c]==1) excl[r].set(c);
        }

    for(int i=1;i<=k;i++){
        int ra=carp[i].a, rb=carp[i].b, ca=carp[i].c, cb=carp[i].d;
        
        bitset<MAXM> col_mask = col_from[ca] & ~col_from[cb+1];

        vector<pair<int,int>> res;
        for(int r=ra; r<=rb; r++){
            bitset<MAXM> hits = excl[r] & col_mask;
            for(int c=(int)hits._Find_first(); c<MAXM; c=(int)hits._Find_next(c))
                res.push_back({r,c});
        }

        cout<<res.size()<<" : ";
        for(auto [x,y]:res) cout<<"("<<x<<","<<y<<") ";
        cout<<"\n";
    }

    return 0;
}
