#include "bits/stdc++.h"
using namespace std;

long long MOD = 1000000007;
long long SUM[401][401] = {};

long long Calc(long long L, long long R, long long K) {
	return (SUM[K][R] - SUM[K][L] + MOD) % MOD;
}

int main() {
	long long N, C;
	cin >> N >> C;
	vector<long long> A(N), B(N);
	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 <= 400; i++) {
		long long NOW = 1;
		for (int j = 0; j <= 400; j++) {
			SUM[j][i] = (SUM[j][i - 1] + NOW) % MOD;
			NOW = (NOW * i) % MOD;
		}
	}
	vector<vector<long long> > DP(N + 1, vector<long long>(C + 1, 0));
	DP[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= C; j++) {
			for (int l = 0; j + l <= C; l++) {
				DP[i + 1][j + l] += (DP[i][j] * Calc(A[i] - 1, B[i], l)) % MOD;
				DP[i + 1][j + l] %= MOD;
			}
		}
	}
	cout << DP[N][C] << endl;
}