#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n,c,dp[405][405],x[405][405],a[2][405];
int main()
{
	for(int i=0;i<=400;i++)x[0][i]=1;
	for(int i=1;i<=400;i++)for(int j=0;j<=400;j++)x[i][j]=1ll*x[i-1][j]*j%mod;
	for(int i=0;i<=400;i++)for(int j=1;j<=400;j++)x[i][j]=(x[i][j]+x[i][j-1])%mod;
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++)scanf("%lld",&a[0][i]);
	for(int i=1;i<=n;i++)scanf("%lld",&a[1][i]);
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=c;j++)
		{
			if(!dp[i][j])continue;
			for(int k=0;k<=c-j;k++)dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j]*(mod+x[k][a[1][i+1]]-x[k][a[0][i+1]-1]))%mod;	
		}	
	}
	printf("%lld\n",dp[n][c]);		
	return 0;
}