#include<iostream>
using namespace std;
long long n, c, a[500], b[500], I[500][500], dp[500][500], mod = 1000000007;
int main() {
	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 j = a[i]; j <= b[i]; j++) {
			long long P = 1;
			for (int k = 0; k <= c; k++) {
				I[i][k] += P; P *= j; P %= mod; I[i][k] %= 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 - 1][k] * I[i - 1][j - k]; dp[i][j] %= mod; }
		}
	}
	cout << dp[n][c] << endl;
	return 0;
}