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

using I = long long;
const I M = 1e9 + 7;

int main() {
  I N, C;
  cin >> N >> C;
  vector<I> A(N), B(N);
  for(auto& i: A) cin >> i;
  for(auto& i: B) cin >> i;

  vector<vector<I>> pow(400+1, vector<I>(C+1, 1));
  for(auto i=1; i<=400; ++i)
    for(auto j=1; j<=C; ++j)
      pow[i][j] = i * pow[i][j-1] % M;

  vector<vector<I>> dp(N+1, vector<I>(C+1, 0));
  for(auto i=0; i<N; ++i)
    for(auto j=0; j<=C; ++j)
      for(auto x=A[i]; x<=B[i]; ++x)
        (dp[i][j] += pow[x][j]) %= M;

  vector<vector<I>> memo(N+1, vector<I>(C+1, -1));
  function<I(I, I)> dfs  = [&](I i, I j) {
    if(i == N) return (j == 0) ? I(1) : I(0);
    if(memo[i][j] != -1) return memo[i][j];
    I res = 0;
    for(auto k=0; k<=j; ++k) (res += dp[i][k] * dfs(i+1, j-k) % M) %= M;
    return memo[i][j] = res;
  };

  cout << dfs(0, C) << endl;
}
