//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define int ll
//#define ld long double
#define all(x) (x).begin(),(x).end()
typedef double dbl;
//typedef  long long ll;
#define pw(x) (1LL << (x))
#define forn(i, n) for (int i = 0; i < (n); i++)
 
namespace fft
 
{
    const int maxBase = 12;
    const int maxN = 1 << maxBase;
 
    struct num
    {
        dbl x, y;
        num(){}
        num(dbl xx, dbl yy): x(xx), y(yy) {}
        num(dbl alp): x(cos(alp)), y(sin(alp)) {}
    };
 
    inline num operator + (num a, num b) { return num(a.x + b.x, a.y + b.y); }
    inline num operator - (num a, num b) { return num(a.x - b.x, a.y - b.y); }
    inline num operator * (num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
    inline num conj(num a) { return num(a.x, -a.y); }
 
    const dbl PI = acos(-1);
 
    num root[maxN];
    int rev[maxN];
    bool rootsPrepared = false;
 
    void prepRoots()
    {
        if (rootsPrepared) return;
        rootsPrepared = true;
        root[1] = num(1, 0);
        for (int k = 1; k < maxBase; ++k)
        {
            num x(2 * PI / pw(k + 1));
            for (int i = pw(k - 1); i < pw(k); ++i)
            {
                root[2 * i] = root[i];
                root[2 * i + 1] = root[i] * x;
            }
        }
    }
 
    int base, N;
    int lastRevN = -1;
    void prepRev()
    {
        if (lastRevN == N) return;
        lastRevN = N;
        forn(i, N) rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (base - 1));
    }
 
    void fft(num *a, num *f)
    {
        forn(i, N) f[i] = a[rev[i]];
        for (int k = 1; k < N; k <<= 1) for (int i = 0; i < N; i += 2 * k) forn(j, k)
        {
            num z = f[i + j + k] * root[j + k];
            f[i + j + k] = f[i + j] - z;
            f[i + j] = f[i + j] + z;
        }
    }
 
    num a[maxN], b[maxN], f[maxN], g[maxN];
    ll A[maxN], B[maxN], C[maxN];
 
    void _multMod(int mod, bool eq)
    {
        forn(i, N)
        {
            int x = A[i] % mod;
            a[i] = num(x & (pw(15) - 1), x >> 15);
        }
        forn(i, N)
        {
            int x = B[i] % mod;
            b[i] = num(x & (pw(15) - 1), x >> 15);
        }
        fft(a, f);
        if (!eq) {
            fft(b, g);
        } else {
            for (int i = 0; i < N; i++) g[i] = f[i];
        }
 
        forn(i, N)
        {
            int j = (N - i) & (N - 1);
            num a1 = (f[i] + conj(f[j])) * num(0.5, 0);
            num a2 = (f[i] - conj(f[j])) * num(0, -0.5);
            num b1 = (g[i] + conj(g[j])) * num(0.5 / N, 0);
            num b2 = (g[i] - conj(g[j])) * num(0, -0.5 / N);
            a[j] = a1 * b1 + a2 * b2 * num(0, 1);
            b[j] = a1 * b2 + a2 * b1;
        }
 
        fft(a, f);
        fft(b, g);
 
        forn(i, N)
        {
            ll aa = f[i].x + 0.5;
            ll bb = g[i].x + 0.5;
            ll cc = f[i].y + 0.5;
            C[i] = (aa + bb % mod * pw(15) + cc % mod * pw(30)) % mod;
        }
    }
 
    void prepAB(int n1, int n2)
    {
        base = 1;
        N = 2;
        while (N < n1 + n2) base++, N <<= 1;
 
        for (int i = n1; i < N; ++i) A[i] = 0;
        for (int i = n2; i < N; ++i) B[i] = 0;
 
        prepRoots();
        prepRev();
    }
 
 
    void mult(int n1, int n2, int mod, bool eq)
    {
        prepAB(n1, n2);
        _multMod(mod, eq);
    }
 
    // HOW TO USE ::
    // -- set correct maxBase
    // -- use mult(n1, n2), multMod(n1, n2, mod) and multLL(n1, n2)
    // -- input  : A[], B[]
    // -- output : C[]
} 
int MOD = 1e9 + 7;
 
ll POW(ll x , ll y){
    if(y == 0) return 1;
    ll ret = POW(x , y/2);
    ret *= ret; ret %= MOD;
    if(y % 2) ret *= x;
    return ret % MOD;
}
int C;
vector<int> multiply(vector<int>& a,vector<int>&b){
  int n1 = a.size();
  int n2 = b.size();
  for(int i = 0;i<=C;i++){
    fft::A[i] = a[i];
  }
  for(int i = 0;i<=C;i++){
    fft::B[i] = b[i];
  }
  fft::mult(C + 2 , C + 2 , MOD , 0);
  vector<int>c(C+1);
  for(int i = 0;i<=C;i++){
    c[i] = fft::C[i];
  }
  return c;
}
vector<vector<int>> v;  
vector<int> solve(int l, int r){
  if(l == r)
    return v[l];
  int mid = (l+r)>>1;
  vector<int> a = solve(l,mid);
  vector<int> b = solve(mid+1,r);
  return multiply(a,b);
}
int32_t main()
{ 
   IOS

  int n;
  cin >> n >> C;
  int a[n],b[n];
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  for(int i = 0;i<n;i++){
    cin >> b[i];
  }
  v.resize(n);
  vector<int> cks[C+1];
  for(int i =  0;i<=C;i++){
    int csum = 0;
    for(int j = 0;j<=400;j++){
      csum = (csum + POW(j,i))%MOD;
      cks[i].push_back(csum);
    }

  }

  for(int i = 0;i<n;i++){
    for(int j = 0;j<=C;j++){
      v[i].push_back((cks[j][b[i]] - cks[j][a[i]-1]+ MOD)%MOD);
    }
  }
  vector<int> ans = solve(0,n-1);
  cout<<ans[C]<<endl;


  
  
    
    




  
}

Measured memory_bytes: 6636