#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <stdio.h>


using namespace std;
#define LL long long
const LL MOD = (LL)1e9+7;
#define FOR(i,s,e) for(i = s; i < e; i++)
LL n,l,i,j,y,key,r,dp[5001][5001],x[5001],a[5001],la[5002];
int main(){
  cin >> n >> l;
  FOR(i,0,n) cin >> x[i];
  FOR(i,0,n) cin >> a[i];
  i = n-1;
  for(r = l-1;r >= 0;r--){
    if (a[i] == 0){
      if (r == x[i]){
        la[i] = r;
        i--;
      }
    }
    else{
      if ((r-x[i])%a[i] == 0){
        la[i] = r;
        i--;
      }
    }
    if (i < 0)break;
  }
  la[n] = l;

  FOR(i,0,n)FOR(j,x[i],la[i+1])dp[i][j] = 0;
  y = x[0];
  while (y < la[1]){
    dp[0][y] = 1;
    y += a[0];
    if (a[0] == 0)break;
  }
  FOR(i,0,la[1]-1)dp[0][i+1] += dp[0][i];
  FOR(i,1,n){
    if (a[i] == 0){
      FOR(j,x[i],la[i+1]){
        dp[i][j] += dp[i][j-1];
        if (j == x[i]) dp[i][j] += dp[i-1][j-1];
        if (dp[i][j] >= MOD)dp[i][j] %= MOD;
      }
    }
    else{
      key = x[i]%a[i];
      FOR(j,x[i],la[i+1]){
        dp[i][j] += dp[i][j-1];
        if (j%a[i] == key) dp[i][j] += dp[i-1][j-1];
        if (dp[i][j] >= MOD)dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[n-1][l-1] << endl;
  return 0;
}

