#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<vector> #define LL long long using namespace std; const int maxx = 1e5+10; struct node{ int l,r; LL w; }tree[maxx*40]; int root[maxx]; struct Node{ int x,y; LL w; bool operator < (const Node & s)const{ return x<s.x; } }point[maxx]; vector<int>vx; vector<int>vy; LL n; int cnt; LL get_val(LL x,LL y){ LL k=min(x,min(n-x+1,min(y,n-y+1))); LL minn=k; k--; LL in=n-2*k; LL out=n*n-in*in; if (x==n-minn+1){ } Else if (y == memory) { return }else if (x==minn){ return out+in* }else { return out+in* } } /// / y partial order President tree maintenance interval and void inserts ( int L, int R & lt, int pre, int now tree[now] tree[now].w+=w; if(l==r){ } int mid=(l+r)>>1; if(pos<=mid)inserts(l,mid,tree[pre].l,tree[now].l,pos,w); else inserts(mid+ } LL query(int L,int R,int l,int r,int ql,int qr){ //区间查询 if(ql<=l && r<=qr){ return tree[R].w-tree[L].w; } int mid=(l+r)>>1; LL ans=0; if (qr<=mid){ return query(tree[L].l,tree[R].l,l,mid,ql,qr); }else if (ql>mid){ return query(tree[L].r,tree[R].r,mid+1,r,ql,qr); }else { return query(tree[L].l,tree[R].l,l,mid,ql,qr)+query(tree[L].r,tree[R].r,mid+1 } } LL cal(LL x) { LL sum = 0; while (x) sum += x % 10, x /= 10; return sum; } int main(){ int T; int m,p; scanf("%d",&T); while(T-- cnt=0 memset(root,0,sizeof memset(tree,0,sizeof scanf("%lld%d%d",&n,&m,&p); vx.clear(); vy.clear(); for(int i=1;i<=m;i++){ scanf("%d%d",&point[i].x,&point[i].y); point[i].w=cal(get_val(point[i].x,point[i].y)); vx.push_back(point[i].x); vy.push_back(point[i].y); } sort(point+1,point+1+m); sort(vx.begin(),vx.end()); sort(vy.begin(),vy.end()); vy.erase(unique(vy.begin(),vy.end()),vy.end()); int sz=vy.size(); for (int i=1;i<=m;i++){ int posy=lower_bound(vy.begin(),vy.end(),point[i].y)-vy.begin()+1; inserts(1,sz,root[i-1],root[i],posy,point[i].w); } while(p--){ int lx,rx,ly,ry; scanf("%d%d%d%d",&lx,&ly,&rx,&ry); lx=lower_bound(vx.begin(),vx.end(),lx)-vx.begin()+1 rx=upper_bound(vx.begin(),vx.end(),rx)- ly=lower_bound(vy.begin(),vy.end(),ly)-vy.begin()+1; ry=upper_bound(vy.begin(),vy.end(),ry)-vy.begin(); if (lx>rx || ly>ry){ printf("0\n"); continue; } printf("%lld\n",query(root[lx-1],root[rx],1,sz,ly,ry)); } } return 0 } /* */