#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const ll MOD=1e9+7;
ll f[444][444],sum[444][444];
int n,c,a[444],b[444];

ll fpow(ll a,ll p){
	ll res=1LL;
	while(p){
		if(p&1LL) res=res*a%MOD;
		a=a*a%MOD;
		p>>=1LL;
	}
	return res;
}

ll dp(int cur,int remain){
	if(cur==n){
		if(remain==0) return 1LL;
		else return 0LL;
	}
	ll &res=f[cur][remain];
	if(~res) return res;
	res=0LL;
	for(int k=0;k<=remain;++k) (res+=sum[cur][k]*dp(cur+1,remain-k)%MOD)%=MOD;
	return res; 
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n>>c;
	for(int i=0;i<n;++i) cin>>a[i];
	for(int i=0;i<n;++i) cin>>b[i];
	for(int i=0;i<n;++i) for(int k=0;k<=c;++k) for(int j=a[i];j<=b[i];++j) (sum[i][k]+=fpow(j,k))%=MOD;
	memset(f,-1,sizeof f);
	cout<<dp(0,c);
}