#include <bits/stdc++.h>

const int mod = 1e9 + 7; 
const int MaxN = 4e2 + 5; 

int n, c; 
int l[MaxN], r[MaxN]; 
int f[MaxN][MaxN], pw[MaxN][MaxN]; 

inline void add(int &x, const int &y)
{
	x += y; 
	(x >= mod) ? (x -= mod) : 0; 
}

int main()
{
//	freopen("candy.in", "r", stdin); 
//	freopen("candy.out", "w", stdout); 
	
	scanf("%d%d", &n, &c); 
	for (int i = 1; i <= n; ++i)
		scanf("%d", l + i); 
	for (int i = 1; i <= n; ++i)
		scanf("%d", r + i); 
	
	for (int i = 1; i <= n; ++i)
		for (int j = l[i]; j <= r[i]; ++j)
		{
			int now = 1; 
			for (int k = 0; k <= c; ++k)
			{
				add(pw[i][k], now); 
				now = 1LL * now * j % mod; 
			}
		}
	
	f[0][0] = 1; 
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= c; ++j)
			for (int k = 0; k <= j; ++k)
				f[i][j] = (f[i][j] + 1LL * f[i - 1][j - k] * pw[i][k]) % mod; 
	
	printf("%d\n", f[n][c]); 
	
	fclose(stdin); 
	fclose(stdout); 
	return 0; 
}