#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int a[404],b[404];
int h[404][404];
int dp[404][404];
int main()
{
	int n,c;
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	memset(h,0,sizeof(h));
	for(int i=1;i<=400;i++)
		h[0][i]=1;
	for(int i=1;i<=400;i++)
		for(int j=1;j<=400;j++)
			h[i][j]=(long long)h[i-1][j]*j%mod;
	for(int i=0;i<=400;i++)
		for(int j=1;j<=400;j++)
			(h[i][j]+=h[i][j-1])%=mod;
	memset(dp,0,sizeof(dp));
	dp[1][c]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			if(dp[i][j])
			{
				for(int k=0;k<=j;k++)
					dp[i+1][j-k]=((long long)dp[i][j]*(h[k][b[i]]-h[k][a[i]-1]+mod)+dp[i+1][j-k])%mod;
			}
	printf("%d",dp[n+1][0]);
	return 0;
}