#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
class in_t{public:
	int a;in_t(){cin>>a;}
	operator int() {return a;}
};
class lin_t{public:
	llint a;lin_t(){cin>>a;}
	operator llint() {return a;}
};
class ld_t{public:
	long double a;ld_t(){cin>>a;}
	operator long double() {return a;}
};
template <uint64_t MOD_ = 1000000007>
class mint_base
{
public:
	static constexpr auto MOD = MOD_;
	static_assert(!(MOD <= 2), "MOD cannot be below 2.");
	static_assert(MOD <= (0xFFFFFFFFFFFFFFFF / 2), "MOD is too big");//加算してオーバーフローしない
	static_assert(MOD <= 0xFFFFFFFF, "MOD is too big");//乗算してオーバーフローしない
	constexpr mint_base<MOD> operator+(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v += other;}
	constexpr mint_base<MOD> operator-(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v -= other;}
	constexpr mint_base<MOD> operator*(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v *= other;}
	constexpr auto operator/(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v /= other;}
	constexpr mint_base<MOD>& operator+=(const mint_base<MOD> &other) noexcept
	{a += other.a;if (MOD <= a) { a -= MOD; };return *this;}
	constexpr mint_base<MOD>& operator-=(const mint_base<MOD> &other) noexcept
	{if (a >= other.a) {a -= other.a;}else {a = (a + MOD) - other.a;}return *this;}
	constexpr mint_base<MOD>& operator*=(const mint_base<MOD> &other) noexcept
	{a *= other.a;a %= MOD;return *this;}
	constexpr mint_base<MOD>& operator/=(const mint_base<MOD> &other) noexcept
	{return *this *= ~other;}
	constexpr mint_base<MOD> operator+()const noexcept { return *this; }
	constexpr mint_base<MOD> operator-()const noexcept
	{return{ MOD - a, mod_value_tag{} };}
	constexpr mint_base<MOD>& operator++() noexcept
	{if (MOD <= ++a) { a = 0; };return *this;}
	constexpr mint_base<MOD>& operator--() noexcept
	{if (a <= 0) { a = MOD; };--a;return *this;}
	constexpr mint_base<MOD> operator++(int) noexcept
	{auto tmp = *this;++*this;return tmp;}
	constexpr mint_base<MOD> operator--(int) noexcept
	{auto tmp = *this;--*this;return tmp;}
	constexpr mint_base<MOD> operator~()const noexcept
	{return ipow(*this, e_phi - 1);}
	constexpr mint_base<MOD>& operator=(const mint_base<MOD> &other) noexcept
	{a = other.a;return *this;}
	constexpr operator uint64_t()const noexcept
	{return a;}
	constexpr explicit operator unsigned()const noexcept
	{return (unsigned)a;}
	static constexpr uint64_t getmod() noexcept
	{return MOD;}
	constexpr mint_base(uint64_t a_) noexcept :a(a_ % MOD) {}
	constexpr mint_base()noexcept : a(0) {}
	struct mod_value_tag {};
	constexpr mint_base(uint64_t a_, mod_value_tag) :a(a_) {}
private:
	static constexpr uint64_t get_e_phi()noexcept {
		//オイラー値の導出
		uint64_t temp = MOD;
		uint64_t m_ = MOD;
		for (uint64_t i = 2; i * i <= m_; ++i)
		{
			if (m_ % i == 0)
			{
				temp = temp / i * (i - 1);
				for (; m_ % i == 0; m_ /= i);
			}
		}
		if (m_ != 1)temp = temp / m_ * (m_ - 1);
		return temp;
	}
	static constexpr uint64_t e_phi = get_e_phi();//オイラー値
	uint64_t a;
};
//mint_base型用の累乗関数
template<uint64_t MOD>constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept
{mint_base<MOD> ReS = 1;
	while (n > 0)
	{
		if (n & 1)ReS *= x;
		x *= x;
		n >>= 1;
	}
	return ReS;
}
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(x)時間が必要
template<uint64_t MOD>std::vector<mint_base<MOD>> fact_set(mint_base<MOD> x = mint_base<MOD>(-1))
{
	mint_base<MOD> ReS(1);
	std::vector<mint_base<MOD>> set((uint64_t)(x)+1);
	set[0] = 1;
	for (uint64_t i = 1; i <= (uint64_t)x; ++i)
	{
		ReS *= i;
		set[i] = ReS;
	}
	return ReS;
}
//mint_base型のstreamへの出力
template<uint64_t MOD> std::ostream& operator<<(std::ostream& os, mint_base<MOD> i)
{os << (uint64_t)i;return os;}
//mint_base型のstreamからの入力
template<uint64_t MOD> std::istream& operator >> (std::istream& is, mint_base<MOD>& i)
{uint64_t tmp;is >> tmp;i = tmp;return is;}
int main(void){
	in_t n,c;
	mint_base<mod> i,j,k;
	vector<vector<mint_base<mod>>>kake(n);//i人目がj個のものをもらうとkake[i][j]倍
	vector<mint_base<mod>> ans(c+1);//現在の答え
	vector<mint_base<mod>> dp(c+1);
	vector<int>A(n);vector<int>B(n);
	ans[0]=1;
	for(i=0;i<n;i++){cin>>A[i];}
	for(i=0;i<n;i++){cin>>B[i];}
	for(i=0;i<n;i++){
		kake[i].res(c+1);
		for(j=A[i];j<=B[i];j++){
			mint_base<mod> now=1;
			for(k=0;k<=c;k++){
				kake[i][k]+=now;
				now*=j;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<=c;j++){dp[j]=0;}
		for(j=0;j<=c;j++){//すた
			for(k=0;j+k<=c;k++){//たす
				dp[j+k]+=ans[j]*kake[i][k];
			}
		}
		swap(dp,ans);
	}
	cout<<ans[c]<<endl;
	return 0;
}

Measured memory_bytes: 1536