// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long LL;



const LL MOD = 1e9+7;



inline LL dmod(LL x){

	return x%MOD;

}



int n,c;



LL pang[405][405];

LL ps[405][405];



void pre(){

	for(int i=0;i<=400;i++) pang[i][0] = 1LL;

	for(int i=1;i<=400;i++){

		for(int j=1;j<=400;j++){

			pang[i][j] = dmod(pang[i][j-1]*(LL)i);

		}

	}

	for(int i=0;i<=400;i++) ps[0][i] = pang[0][i];

	for(int i=1;i<=400;i++){

		for(int j=0;j<=400;j++){

			ps[i][j] = dmod(ps[i-1][j] + pang[i][j]);

		}

	}

}



//int n,c;

int A[405],B[405];



LL memo[405][405];



LL dp(int id, int sisa){

	if(id > n){

		if(sisa == 0) return 1LL;

		else return 0LL;

	}

	LL &ret = memo[id][sisa];

	if(ret!=-1) return ret;

	ret = 0LL;

	for(int i=0;i<=sisa;i++){

		ret = dmod(ret+dmod(dp(id+1,sisa-i)*dmod(ps[B[id]][i] - ps[A[id]][i]+MOD)));

	}

	return ret;

}



int main(){

	pre();

//	for(int i=0;i<=5;i++){

//		for(int j=0;j<=5;j++){

//			cout << ps[i][j] << " ";

//		}

//		cout << endl;

//	}

	memset(memo,-1,sizeof(memo));

	cin >> n >> c;

	for(int i=1;i<=n;i++){

		cin >> A[i];

		A[i]--;

	}

	for(int i=1;i<=n;i++){

		cin >> B[i];

	}

	LL ans = dp(1,c);

	cout << ans << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1378936956787156x):
#include<bits/stdc++.h>



using namespace std;

#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define FI first

#define SE second

#define MP make_pair

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;

typedef pair < ll , ll > pll;



const double PI = acos(-1);

const double EPS = 1e-9;

const ll MOD = 1e9 + 7;

const int INF = 1e9;

	



ll addMod(ll a, ll b){

	if(a + b >= MOD) return a + b - MOD;

	return a + b;

}



ll mulMod(ll a, ll b){

	return (a*b)%MOD;

}



ll fast(ll a, ll b){

	if(b == 0) return 1;

	ll tmp = fast(a,b/2);

	tmp = mulMod(tmp,tmp);

	if(b%2 == 1) tmp = mulMod(tmp,a);

	return tmp;

}



ll GCD(ll a, ll b){

	if(a > b) return GCD(b,a);

	if(a == 0) return b;

	return GCD(b%a,a);

}



//////////////////////////////////////////////



const int N = 400;



int n,m;

ll dp[N + 5][N + 5];

ll tot[N + 5][N + 5];

int A[N + 5], B[N + 5];



ll solve(int idx, int rem){

	if(idx == n+1){

		if(rem == 0) return 1;

		return 0;

	}

	ll& ret = dp[idx][rem];

	if(ret != -1) return ret;

	ret = 0;

	FOR(i,rem+1){

		ret = addMod(ret, mulMod(solve(idx+1,rem-i), addMod(tot[i][B[idx]], MOD - tot[i][A[idx]-1])));

	}

	return ret;

	

}

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	FOR(i,N+2){

		FOR(j,N+2){

			tot[i][j] = (i == 0) ? 1 : mulMod(tot[i-1][j], (ll)j);

		}

	}

	FOR(i,N+2){

		tot[i][0] = 0;

		REP(j,1,N){

			tot[i][j] = addMod(tot[i][j], tot[i][j-1]);

		}

	}

	cin >> n >> m;

	REP(i,1,n) cin >> A[i];

	REP(i,1,n) cin >> B[i];

	memset(dp,-1,sizeof dp);

	cout << solve(1,m) << endl;

	return 0;

}