1 #include "bits/stdc++.h"
2 #define mp(a,b) (Vec){a,b}
3 #define fi first
4 #define se second
5 using namespace std;
6 typedef long long LL;
7 const int MAX=2005;
8 LL n,m;
9 LL x[MAX],y[MAX],qx[MAX],qy[MAX];
10 LL ans[MAX];
11 struct Vec{
12 LL x,y;
13 };
14 bool operator <(Vec rr,Vec tt){
15 if (rr.x!=tt.x) return rr.x<tt.x;
16 return rr.y<tt.y;
17 }
18 map <Vec,LL> q;
19 inline LL gcd(LL cc,LL vv){return (vv==0?cc:gcd(vv,cc%vv));}
20 int main(){
21 freopen ("a.in","r",stdin);
22 freopen ("a.out","w",stdout);
23 LL i,j,zt,gg;
24 LL zx,zy,cx,cy;
25 scanf("%lld%lld",&n,&m);
26 for (i=1;i<=n;i++) scanf("%lld%lld",x+i,y+i);
27 for (i=1;i<=m;i++) scanf("%lld%lld",qx+i,qy+i);
28 for (i=1;i<=m;i++){
29 q.clear();
30 for (j=1;j<=n;j++){
31 zx=x[j]-qx[i];
32 zy=y[j]-qy[i];
33 gg=gcd(abs(zx),abs(zy));
34 if (gg!=0) zx/=gg,zy/=gg;
35 if (zx<0) zx*=-1,zy*=-1;
36 if (zx==0) zy=abs(zy);
37 if (zy==0) zx=abs(zx);
38 q[mp(zx,zy)]++;
39 }
40 zt=0;
41 for (j=1;j<=n;j++){
42 zx=x[j]-qx[i];
43 zy=y[j]-qy[i];
44 gg=gcd(abs(zx),abs(zy));
45 if (gg!=0) zx/=gg,zy/=gg;
46 if (zx<0) zx*=-1,zy*=-1;
47 if (zx==0) zy=abs(zy);
48 if (zy==0) zx=abs(zx);
49 cx=-zy;
50 cy=zx;
51 if (cx==0) cy=abs(cy);
52 if (cy==0) cx=abs(cx);
53 if (cx<0) cx*=-1,cy*=-1;
54 if (q.find(mp(cx,cy))!=q.end())
55 zt+=q[mp(cx,cy)];
56 }
57 ans[i]+=zt/2;
58 }
59 for (i=1;i<=n;i++){
60 q.clear();
61 for (j=1;j<=n;j++){
62 if (i==j) continue;
63 zx=x[j]-x[i];
64 zy=y[j]-y[i];
65 gg=gcd(abs(zx),abs(zy));
66 if (gg!=0) zx/=gg,zy/=gg;
67 if (zx<0) zx*=-1,zy*=-1;
68 if (zx==0) zy=abs(zy);
69 if (zy==0) zx=abs(zx);
70 q[mp(zx,zy)]++;
71 }
72 for (j=1;j<=m;j++){
73 zx=x[i]-qx[j];
74 zy=y[i]-qy[j];
75 gg=gcd(abs(zx),abs(zy));
76 if (gg!=0) zx/=gg,zy/=gg;
77 if (zx<0) zx*=-1,zy*=-1;
78 if (zx==0) zy=abs(zy);
79 if (zy==0) zx=abs(zx);
80 cx=-zy;
81 cy=zx;
82 if (cx==0) cy=abs(cy);
83 if (cy==0) cx=abs(cx);
84 if (cx<0) cx*=-1,cy*=-1;
85 if (q.find(mp(cx,cy))!=q.end())
86 ans[j]+=q[mp(cx,cy)];
87 }
88 }
89 for (i=1;i<=m;i++)
90 printf("%lld\n",ans[i]);
91 return 0;
92