M=1e9+7;a[99];i,j,p,q,s,f;long T,S;main(t){for(;~scanf("%d",a+j++););for(;i++<1<<20;S+=T*!j){for(f=s=p=q=j=0;j<5;f|=t>a[3*j+2])s+=t=i>>j*4&15,p+=t*a[3*++j],q+=t*a[3*j+1];for(T=1;p-a[0]|q-a[1]|f?0:t?T=T%t?T+M:(T/t--*s--)%M:(t=i>>--j*4-4&15,j););}printf("%d",S%M);}