// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 3.4366462643933553x):
/*

  mail: mleautomaton@foxmail.com

  author: MLEAutoMaton

  This Code is made by MLEAutoMaton

*/

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<math.h>

#include<algorithm>

#include<queue>

#include<set>

#include<map>

#include<iostream>

using namespace std;

#define ll long long

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

#define re register

#define int ll

#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)

inline int gi(){

	int f=1,sum=0;char ch=getchar();

	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}

	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}

	return f*sum;

}

const int N=410,Mod=1e9+7;

int a[N],b[N],n,sum[N][N],c,dp[N][N];

int val(int i,int Q){

	return (sum[Q][b[i]]-sum[Q][a[i]-1]+Mod)%Mod;

}

int qpow(int a,int b){

	int ret=1;

	while(b){

		if(b&1)ret=1ll*ret*a%Mod;b>>=1;

		a=1ll*a*a%Mod;

	}

	return ret;

}

signed main(){

	n=gi();c=gi();

	for(int i=1;i<=n;i++)a[i]=gi();for(int i=1;i<=n;i++)b[i]=gi();

	for(int i=0;i<=c;i++)

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

			sum[i][j]=(sum[i][j-1]+qpow(j,i))%Mod;

	dp[0][0]=1;

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

		for(int j=0;j<=c;j++)

			for(int k=0;k<=j;k++)

				dp[i][j]=(dp[i][j]+1ll*dp[i-1][k]*val(i,j-k)%Mod)%Mod;

	printf("%lld\n",dp[n][c]);

	return 0;

}