#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];
long long sum[MAXN][MAXN];
vector< pair<int,int> > ans[MAXK];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m>>k;

    assert(n>=1 and n<=5000);
    assert(m>=1 and m<=5000);
    assert(k>=1 and k<=100000);

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

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

       // assert(1<=a and a<=b and b<=n);
       // assert(1<=c and c<=d and d<=m);

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

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

        sum[a][c]+=i;
        sum[a][d+1]-=i;
        sum[b+1][c]-=i;
        sum[b+1][d+1]+=i;
    }

    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];
            sum[i][f]+=sum[i-1][f] + sum[i][f-1] - sum[i-1][f-1];

            if(cover[i][f]==1)ans[sum[i][f]].push_back({i,f});
        }
    }

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

    return 0;
}