
#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];

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 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];

    for(int i=1;i<=k;i++){
        int a=carp[i].a, c=carp[i].c;
        if(cover[a][c]==1)
            cout<<"1 : ("<<a<<","<<c<<") \n";
        else
            cout<<"0 : \n";
    }

    return 0;
}
