1 /*by SilverN*/
2 #include<algorithm>
3 #include<iostream>
4 #include<cstring>
5 #include<cstdio>
6 #include<cmath>
7 #include<vector>
8 #define LL long long
9 using namespace std;
10 const int mod=1e9+7;
11 const int mxn=1200000;
12 int read(){
13 int x=0,f=1;char ch=getchar();
14 while(ch<‘0‘ || ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
15 while(ch>=‘0‘ && ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
16 return x*f;
17 }
18 struct point{
19 int x,y;
20 bool operator < (const point b)const{return x<b.x;}
21 }s[mxn];
22 int n,Ex,Ey;
23 int ax,ay,bx,by;
24 int SA,SB;
25 LL fac[mxn];
26 LL inv[mxn];
27 void init(){
28 fac[1]=1;inv[1]=1;
29 fac[0]=1;inv[0]=1;
30 for(int i=2;i<mxn;i++){
31 fac[i]=(LL)fac[i-1]*i%mod;
32 inv[i]=((-mod/i)*inv[mod%i]%mod+mod)%mod;
33 }
34 for(int i=2;i<mxn;i++) inv[i]=inv[i]*inv[i-1]%mod;
35 // for(int i=1;i<=100;i++)printf("i:%d %lld\n",i,inv[i]);
36 return;
37 }
38 bool GST(int u,int v){
39 int x0=s[v].x-s[u].x;
40 int y0=s[v].y-s[u].y;
41 int a=x0*ay-y0*ax,b=bx*ay-by*ax;
42 if(a%b)return 0;else SA=a/b;
43 a=x0*by-y0*bx,b=ax*by-ay*bx;
44 if(a%b)return 0;else SB=a/b;
45 return 1;
46
47 /* int tmp=y0*ax-x0*ay;
48 int t2=ax*by-ay*bx;
49 if(tmp%t2)return 0;
50 else SB=tmp/t2;
51 tmp=y0*bx-x0*by;
52 t2=bx*ay-by*ax;
53 if(tmp%t2)return 0;
54 else SA=tmp/t2;
55 return 1;*/
56 }
57 inline LL calc(int n,int m){
58 if(n<m)return 0;
59 return fac[n]*inv[m]%mod*inv[n-m]%mod;
60 }
61 LL f[mxn];
62 void solve(){
63 int i,j;
64 // printf("%d %d %d %d\n",ax,ay,bx,by);
65 for(i=1;i<=n;i++){
66 if(!GST(0,i))continue;
67 // printf("x:%d y:%d\n",s[i].x,s[i].y);
68 // printf("SA:%d SB:%d\n",SA,SB);
69 f[i]=calc(SA+SB,SA);
70 for(j=1;j<i;j++){
71 // if(s[j].x<=s[i].x && s[j].y<=s[i].y){
72 if(!GST(j,i))continue;
73 // printf("j%d:SA:%d SB:%d %lld\n",j,SA,SB,calc(SA+SB,SA));
74 f[i]=(f[i]-(f[j]*calc(SA+SB,SA))%mod+mod)%mod;
75 // }
76 }
77 // printf("f[%d]:%lld\n",i,f[i]);
78 }
79 printf("%lld\n",f[n]);
80 return;
81 }
82 int main(){
83 // freopen("in.txt","r",stdin);
84 init();
85 int i,j;
86 Ex=read();Ey=read();n=read();
87 ax=read();ay=read();bx=read();by=read();
88 for(i=1;i<=n;i++){
89 s[i].x=read(),s[i].y=read();
90 /* if(s[i].x>Ex || s[i].y>Ey){
91 i--;n--;
92 }*/
93 }
94 ++n;s[n].x=Ex,s[n].y=Ey;
95 if(!GST(0,n)){
96 printf("0\n");return 0;
97 }
98 sort(s+1,s+n);
99 solve();
100 return 0;
101 }