#include <iostream>

using namespace std;
typedef long long ll;
const int MAX_N = 400, MAX_C = 400;
const ll MOD = 1000000007;

ll dp[MAX_N+1][MAX_C+1] = {1};
ll lsw[MAX_N+1][MAX_C+1];

int main() {
	int N, C;
	ll a[MAX_N], b[MAX_N];
	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<=MAX_N;i++) {
		for(int j=0;j<=MAX_C;j++) {
			if(i==0) lsw[i][j] = !!j;
			else lsw[i][j] = lsw[i-1][j] * j % MOD;
		}
	}
	for(int i=0;i<=MAX_N;i++) {
		for(int j=1;j<=MAX_C;j++) {
			lsw[i][j] += lsw[i][j-1];
			lsw[i][j] %= MOD;
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=0;j<=C;j++) {
			for(int k=0;k<=j;k++) {
				ll tmp = lsw[j-k][b[i-1]] - lsw[j-k][a[i-1]-1] + MOD;
				tmp %= MOD;
				dp[i][j] += dp[i-1][k] * tmp;
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[N][C] << endl;
	return 0;
}
