#include<bits/stdc++.h>
using namespace std;

#undef _GLIBCXX_DEBUG

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true": "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << "\033[33;0m" << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

template <typename T>
void debug_out (T a[], int n) {
	cerr << "{" << to_string(a[0]);
	for (int i = 1; i < n; ++i) cerr << ", " << to_string(a[i]);
	cerr << "}";
	debug_out();
}

#define LOCAL

#ifdef LOCAL
#define dbg(...)  cerr << "\033[33;1m" << "[" << #__VA_ARGS__ << "] : ", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

using LL = long long;
using PII = pair<int,int>;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x.size()))
#define sqr(x) ((x)*(x))

LL powmod (LL a, LL b, LL MOD) {
	LL ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return ans % MOD;
}

const int N = 100005, MOD = 1e9+7, INF = 1e9;

// head


//dp(i,j) 前i个人分了j个糖果的乘积和
/*
  for i in [1,n]
  	for j in [0,c]
  		for k in [0,c-j]
  			for p in [a_i,b_i]
  				dp[i][j+k] += dp[i-1][j] * p^k
  预处理1~c的k次方前缀和即可
  dp[0][0] = 1
 */
LL dp[405][405], sum[405][405], a[405], b[405], n, c;
void init () {
	for (int i = 1; i < 405; ++i)
		for (int j = 0; j < 405; ++j)
			sum[i][j] = (sum[i-1][j] + powmod(i,j,MOD)) % MOD;
	cin >> n >> c;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= c; ++j) {
			for (int k = 0; k <= c-j; ++k) {
				dp[i][j+k] += dp[i-1][j] * (sum[b[i]][k]-sum[a[i]-1][k]+MOD)%MOD;
				dp[i][j+k] %= MOD;
			}
		}
	}
	cout << dp[n][c] << endl;
}

void work () {
}

int main () {
	time_t tic = clock();
	int T = 1;
	//scanf ("%d",&T);
	while (T--) {
		init ();
		work ();
	}
	time_t toc = clock();
	cerr << "execute time = " << (toc-tic) / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 2816