#include <bits/stdc++.h>
using namespace std;
ifstream fin("zoo.in");
ofstream fout("zoo.out");
const int mxnm = 116005;
struct pt{
int xs, ys, xf, yf;
}pts[100005];
int n, m;
int vf;
pair<int, int> crd[16005];
int cpx[mxnm + 5], cpy[mxnm + 5];
unordered_map<int ,int > mp;
int main()
{
fin >> n;
for(int i = 1; i <= n; ++i)
fin >> crd[i].first >> crd[i].second;
fin >> m;
for(int i =1; i <= m; ++i)
fin >> pts[i].xs >> pts[i].ys >> pts[i].xf >> pts[i].yf;
for(int i = 1; i <= n; ++i)
cpx[i] = crd[i].first, cpy[i] = crd[i].second;
vf = n;
for(int i = 1; i <= m; ++i)
cpx[vf + 1] = pts[i].xs, cpx[vf + 2] = pts[i].xf, cpy[vf + 1] = pts[i].ys, cpy[vf + 2] = pts[i].yf, vf+=2;
sort(cpx + 1, cpx + vf + 1);
sort(cpy + 1, cpy + vf + 1);
for(int i = 1; i <= vf; ++i)
mp[cpx[i]] = i;
for(int i = 1; i <= n; ++i)
crd[i].first = mp[crd[i].first];
for(int i = 1; i <= m; ++i)
pts[i].xs = mp[pts[i].xs], pts[i].xf = mp[pts[i].xf];
mp.clear();
for(int i = 1; i <= vf; ++i)
mp[cpy[i]] = i;
for(int i = 1; i <= n; ++i)
crd[i].second = mp[crd[i].second];
for(int i = 1; i <= m; ++i)
pts[i].ys = mp[pts[i].ys], pts[i].yf = mp[pts[i].yf];
sort(crd + 1, crd + n + 1);
for(int i = 1; i <= m; ++i)
{
int p1, p2;
p1 = p2 = 0;
pair<int, int> pp = {pts[i].xs, 0};
p1 = lower_bound(crd + 1, crd + n + 1, pp) - crd;
pp = {pts[i].xf, 0};
p2 = upper_bound(crd + 1, crd + n + 1, pp) - crd;
int yy1, yy2;
yy1 = pts[p1].ys;
yy2 = pts[p2].yf;
/// (p2, y2) - (p2, y1-1) - (p2-1, y2) + (p1-1, y1-1)
}
fin.close();
fout.close();
return 0;
}