#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集
template<typename T>
struct SegmentTree{

  vector<T> node;
  int n0;
  SegmentTree(vector<T>& v){
    int n = v.size();
    n0 = 1;
    while(n0 < n) n0 <<= 1;
    node.assign(2*n0,0);

    for(int i=0; i<n; i++) node[i+n0-1] = v[i];
    for(int i=n0-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
  }

  void update(int k, T x){
    k += n0-1;
    node[k] = x;
    while(k > 0){
      k = (k-1)/2;
      node[k] = node[k*2+1] + node[k*2+2];
    }
  }

  /* 区間[l,r]の和 */
  T query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return 0;
    
    if(a <= l && r <= b) return node[k];
    else{

      T vl = query(a, b, 2*k+1, l, (l+r)/2);
      T vr = query(a, b, 2*k+2, (l+r)/2, r);
      return vl + vr;
    }
  
  }
  
  /* 区間[0, n)中のk番目の1のindex*/
  int find_kth(int v, int l, int r, int k){
    if(k > node[v]) return -1;
    if(l + 1 == r) return l;
    if(node[v*2+1] >= k){
      return find_kth(v*2+1, l, (l+r)/2, k);
    }else{
      return find_kth(v*2+2, (l+r)/2, r, k-node[v*2+1]);
    }
  }


  T query(int l, int r){
    return query(l, r, 0, 0, n0);
  }

  T find_kth(int k){
    if(k == 0) return -1;
    return find_kth(0, 0, n0, k);
  }
  
};
ll modPow(ll x, ll n, ll mod = MOD){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x)%mod;
 
        res %= mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}
ll dp[410][410];
ll cum[410][410];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  int N, C; cin >> N >> C;
  REP(i,C+1){
    for(int j=0; j<=400; j++){
      cum[i][j+1] = cum[i][j] + modPow(j, i, MOD);
      cum[i][j+1] %= MOD;
    }
  }
  vector<int> A(N), B(N);
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];
  dp[0][0] = 1;
  for(int i=0; i<N; i++){

    for(int j=0; j<=C; j++){

      for(int k=0; k<=C; k++){
        if(j + k > C) break;
        dp[i+1][j+k] += dp[i][j] * (cum[k][B[i]+1] - cum[k][A[i]] + MOD) % MOD;
        dp[i+1][j+k] %= MOD;
      }
    }
  }
  cout << dp[N][C] << endl;
  return 0;
}

Measured memory_bytes: 6236