#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[11005][11005],ans[11005];
struct rect
{
long long x,y,w,h;
};
bool cmp(rect a, rect b)
{
return a.h*a.w>b.h*b.w;
}
int main()
{
long long n,m;
rect r[11005];
cin>>n>>m;
ans[0]=n*m;
long long k;
cin>>k;
for(long long i=1;i<=k;i++)
{
cin>>r[i].x>>r[i].y>>r[i].w>>r[i].h;
}
sort(r+1,r+k+1,cmp);
for(long long i=1;i<=k;i++)
{
int xx,yy;
int flag=0;
xx=r[i].x;
yy=r[i].y;
while(1)
{
if(a[xx][yy]!=0)
{
if(r[a[xx][yy]].h>r[i].y-yy){ ans[a[r[i].x][yy]]=ans[a[r[i].x][yy]]-((r[i].h)*(r[i].w));flag=1; break;}
}
yy--;
if(yy<0){break;}
}
ans[i]=(r[i].h)*(r[i].w);
if(flag==0)ans[0]=ans[0]-((r[i].h)*(r[i].w));
for(long long p=r[i].x;p<r[i].x+r[i].w;p++)
{
a[p][r[i].y]=i;
}
}
long long t;
cin>>t;
for(long long i=1;i<=t;i++)
{
long long xx,yy,yys;
cin>>xx>>yy;
yys=yy;
while(1)
{
if(a[xx][yy]!=0)
{
if(r[a[xx][yy]].h>yys-yy){cout<<ans[a[xx][yy]]<<endl;break;}
}
yy--;
if(yy<0){cout<<ans[0]<<endl;break;}
}
}
return 0;
}
// 11 7 3 2 1 5 5 8 2 2 3 3 2 3 2 4 4 3 3 5 10 1 9 3
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmxvbmcgbG9uZyBhWzExMDA1XVsxMTAwNV0sYW5zWzExMDA1XTsKc3RydWN0IHJlY3QKewogICAgbG9uZyBsb25nIHgseSx3LGg7Cn07CmJvb2wgY21wKHJlY3QgYSwgcmVjdCBiKQp7CiAgICByZXR1cm4gYS5oKmEudz5iLmgqYi53Owp9CmludCBtYWluKCkKewoKICAgIGxvbmcgbG9uZyBuLG07CiAgICByZWN0IHJbMTEwMDVdOwogICAgY2luPj5uPj5tOwogICAgYW5zWzBdPW4qbTsKICAgIGxvbmcgbG9uZyBrOwogICAgY2luPj5rOwogICAgZm9yKGxvbmcgbG9uZyBpPTE7aTw9aztpKyspCiAgICB7CiAgICAgICAgY2luPj5yW2ldLng+PnJbaV0ueT4+cltpXS53Pj5yW2ldLmg7CiAgICB9CiAgICBzb3J0KHIrMSxyK2srMSxjbXApOwogICAgZm9yKGxvbmcgbG9uZyBpPTE7aTw9aztpKyspCiAgICB7CgoKICAgICAgICAgICAgaW50IHh4LHl5OwogICAgICAgICAgICBpbnQgZmxhZz0wOwogICAgICAgICAgICB4eD1yW2ldLng7CiAgICAgICAgICAgIHl5PXJbaV0ueTsKICAgICAgICAgICAgd2hpbGUoMSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoYVt4eF1beXldIT0wKQogICAgICAgICAgICAgICAgewoKICAgICAgICAgICAgICAgICAgICBpZihyW2FbeHhdW3l5XV0uaD5yW2ldLnkteXkpeyBhbnNbYVtyW2ldLnhdW3l5XV09YW5zW2FbcltpXS54XVt5eV1dLSgocltpXS5oKSoocltpXS53KSk7ZmxhZz0xOyBicmVhazt9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIHl5LS07CiAgICAgICAgICAgICAgICBpZih5eTwwKXticmVhazt9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYW5zW2ldPShyW2ldLmgpKihyW2ldLncpOwogICAgICAgICAgICBpZihmbGFnPT0wKWFuc1swXT1hbnNbMF0tKChyW2ldLmgpKihyW2ldLncpKTsKICAgICAgICBmb3IobG9uZyBsb25nIHA9cltpXS54O3A8cltpXS54K3JbaV0udztwKyspCiAgICAgICAgewoKCiAgICAgICAgICAgICAgICBhW3BdW3JbaV0ueV09aTsKCiAgICAgICAgfQogICAgfQogICAgbG9uZyBsb25nIHQ7CiAgICBjaW4+PnQ7CgogICAgZm9yKGxvbmcgbG9uZyBpPTE7aTw9dDtpKyspCiAgICB7CiAgICAgICAgbG9uZyBsb25nIHh4LHl5LHl5czsKICAgICAgICBjaW4+Pnh4Pj55eTsKICAgICAgICB5eXM9eXk7CiAgICAgICAgd2hpbGUoMSkKICAgICAgICB7CiAgICAgICAgICAgIGlmKGFbeHhdW3l5XSE9MCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoclthW3h4XVt5eV1dLmg+eXlzLXl5KXtjb3V0PDxhbnNbYVt4eF1beXldXTw8ZW5kbDticmVhazt9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeXktLTsKICAgICAgICAgICAgaWYoeXk8MCl7Y291dDw8YW5zWzBdPDxlbmRsO2JyZWFrO30KICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gMDsKfQovLyAxMSA3IDMgMiAxIDUgNSA4IDIgMiAzIDMgMiAzIDIgNCA0IDMgMyA1IDEwIDEgOSAzCg==