#include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll read() { ll s=0; bool f=0; char ch=' '; while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();} while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();} return (f)?(-s):(s); } #define R(x) x=read() inline void write(ll x) { if(x<0) {putchar('-'); x=-x;} if(x<10) {putchar(x+'0'); return;} write(x/10); putchar((x%10)+'0'); } #define W(x) write(x),putchar(' ') #define Wl(x) write(x),putchar('\n') const ll Base=998244353; const int N=100005; int n,nn,m,Q; struct Node { ll x,y; inline bool operator==(const Node &tmp)const { return x*tmp.y==y*tmp.x; } }a[15]; inline bool cmp(Node p,Node q) { if(p.y*q.y<0) return (p.x*q.y<p.y*q.x); else return (p.x*q.y>p.y*q.x); } map<ll,int>Zer,Map[N]; int main() { freopen("laser.in","r",stdin); freopen("laser.out","w",stdout); int i,j,x,y; R(n); for(i=1;i<=n;i++) { R(a[i].x); R(a[i].y); } sort(a+1,a+n+1,cmp); nn=unique(a+1,a+n+1)-a-1; R(m); for(i=1;i<=m;i++) { R(x); R(y); Zer[x*Base+y]++; for(j=1;j<=nn;j++) { Map[j][x*a[j].y-y*a[j].x]++; } } R(Q); while(Q--) { R(x); R(y); int ans=0; ans-=Zer[x*Base+y]*(nn-1); for(i=1;i<=nn;i++) ans+=Map[i][x*a[i].y-y*a[i].x]; Wl(ans); } return 0; }View Code