// 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.389599951236327x):
#include<bits/stdc++.h>

using namespace std;

typedef double db;

typedef long long ll;

typedef pair<int, int> pii;

#define fi first

#define se second

#define empb emplace_back

#define all(x) (x).begin(),(x).end()

#define lbd(a, x) lower_bound(all(a), x)

const int mod = 1e9 + 7;

int power_mod(int a, int b) {

	int res = 1;

	for(; b; b >>= 1, a = (ll) a * a % mod)

		if(b & 1) res = (ll) res * a % mod;

	return res;

}

#define sz(x) (int)(x).size()

const int N = 410;

int n, C;

int a[N], b[N], pw[N][N];

vector<int> multiply(const vector<int> &a, const vector<int> &b) {

	vector<int> c(sz(a) + sz(b));

	for(int i = 0; i < sz(a); i++)

		for(int j = 0; j < sz(b); j++)

			c[i + j] = (c[i + j] + (ll) a[i] * b[j]) % mod;

	if(c.size() > C + 1) c.resize(C + 1);

	return c;

}

vector<int> work(int l, int r) {

	if(l == r) {

		vector<int> ret(C + 1, 0);

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

			ret[i] = (pw[b[l]][i] - pw[a[l]-1][i] + mod) % mod;

		}

		return ret;

	}

	int mid = (l + r) >> 1;

	auto al = work(l, mid);

	auto ar = work(mid + 1, r);

	return multiply(al, ar);

}

int main() {

#ifdef local

	freopen("in.txt", "r", stdin);

#endif

	ios::sync_with_stdio(false);

	cin.tie(0), cout.tie(0);

	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 = 1; i < N; i++) {

		for(int k = 0; k <= C; k++) {

			pw[i][k] = power_mod(i, k);

			pw[i][k] = (pw[i][k] + pw[i - 1][k]) % mod;

		}

	}

	auto z = work(0, n - 1);

	cout << z[C] << '\n';

	return 0;

}