#include <iostream>
#include <cstdio>
#include <cstring>
#define int long long
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=405;
const int Mod=1000000007;
struct node{int l,r;}a[N];
int n,C,f[N][N],p[N];

signed main(){
	n=read();C=read();
	for(int i=1;i<=n;i++) a[i].l=read();
	for(int i=1;i<=n;i++) a[i].r=read();
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int i=0;i<N;i++) p[i]=0;
		for(int x=a[i].l;x<=a[i].r;x++){
			int ret=1;p[0]++;
			for(int j=1;j<=C;j++){
				ret=ret*x%Mod;p[j]=(p[j]+ret)%Mod;
			}
		}
		for(int j=0;j<=C;j++){
			for(int k=0;k<=j;k++){
				f[i][j]=(f[i][j]+f[i-1][j-k]*p[k]%Mod)%Mod;
			}
		}
	}
	printf("%lld\n",f[n][C]);
	return 0;
}
