// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 400 + 10, mod = 1e9 + 7;
ll dp[MAXN][MAXN], sum[MAXN][MAXN];
int a[MAXN], b[MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, c; cin >> n >> c;
	for(int i = 0; i < n; i ++) cin >> a[i];
	for(int i = 0; i < n; i ++)	cin >> b[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i ++){
		for(int j = a[i - 1]; j <= b[i - 1]; j ++){
			ll tmp = 1;
			for(int t = 0; t <= c; t ++){
				sum[i][t] = (sum[i][t] + tmp) % mod;
				tmp = 1ll * tmp * j % mod; 
			}
		}
	}
	for(int i = 1; i <= n; i ++){
		for(int j = 0; j <= c; j ++){
			for(int t = 0; t <= j; t ++){
				dp[i][j] = (dp[i][j] + dp[i - 1][j - t] * sum[i][t] % mod) % mod;
			}
		}
	}
	cout << dp[n][c] << endl;
	return 0;	
}