#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007
int N,L;
int x[5010],a[5010];
int dp[5010][5010];
int rec(int i,int j)
{
	if(j==N)return 1ll;
	if(i==L)return 0ll;
	if(dp[i][j]!=-1)return dp[i][j];
	ll res =  rec(i+1,j);
	if((a[j]==0&&i==x[j])||(a[j]!=0&&i>=x[j]&&(i-x[j])%a[j]==0))res = (res+rec(i+1,j+1))%MOD;
	return dp[i][j]=res;
}
int main()
{
	scanf("%d %d",&N,&L);
	rep(i,N)scanf("%d",&x[i]);
	rep(i,N)scanf("%d",&a[i]);
	memset(dp,-1,sizeof(dp));
	printf("%d\n",rec(0,0));
	return 0;
}