#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
int N,L;
ll c[2][5001],mod=1e9+7;
ll x[5000],a[5000];
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
int main(){
	cin>>N>>L;
	rep(i,N) cin>>x[i];
	rep(i,N) cin>>a[i];
	rep(i,N){
		int id=N-1-i;
		ll sum=0;
		if(i==0) sum=1;
		rep(j,5001) c[1-i%2][j]=0;
		for(int j=L-1;j>=x[id];j--){
			if(a[id]!=0&&(j-x[id])%a[id]==0) add(c[1-i%2][j],sum);
			if(a[id]==0&&j==x[id]) add(c[1-i%2][j],sum);
			sum+=c[i%2][j];
		}
	}
	ll ans=0;
	rep(i,L) add(ans,c[N%2][i]);
	cout<<ans<<endl;
}