// Original C++ solution (slower):
//

/*==========================================================*/

/*    Template ver 2017-0720    |    Created by JollyBee    */

/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */

/*==========================================================*/

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef pair<ll,ll> pll;

typedef vector<pii> vii;

const double EPS=(double)1e-9;

const double PI=(double)acos(-1.0);

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define pob pop_back

#define pf push_front

#define pof pop_front

#define FOR(i,n) for(int i=0;i<n;i++)

#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)

#define REP(i,l,r) REPP(i,l,r,1)

#define FORD(i,n) for(int i=n-1;i>=0;i--)

#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)

#define REV(i,l,r) REVV(i,l,r,1)

//random

int irand(int lo, int hi){

    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;

}

//ll to string

string toString(ll x) {

    stringstream ss;

    ss << x;

    return ss.str();

}

//string to ll

ll toNumber(string S) {

    ll ret;

    sscanf(S.c_str(),"%lld",&ret);

    return ret;

}

// std::fill(start, end, value);

// for(auto it: DS){}



const int INF=(int)2e9;

const ll MOD=(ll)1e9+7;

/*==========================================================*/

/*                     END OF TEMPLATE                      */

/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */

/*==========================================================*/



ll table[405][405];

int start(){

    REP(i,0,400){

        table[i][0] = (ll)1;

        REP(j,1,400) table[i][j] = (table[i][j-1] * (ll)i) % MOD;

    }

    REP(j,0,400) REP(i,1,400) (table[i][j] += table[i-1][j]) %= MOD;

    return 0;

}



pii dat[405];

ll cost[405][405];

ll dp[405][405];



int main(){

    start();

    // input

    int n,c; scanf("%d %d", &n, &c);

    REP(i,1,n) scanf("%d", &dat[i].fi);

    REP(i,1,n) scanf("%d", &dat[i].se);

    // get cost

    REP(i,1,n) REP(j,0,c){

        ll ret = table[dat[i].se][j] - table[dat[i].fi-1][j] + MOD;

        cost[i][j] = ret % MOD;

    }

    // dp

    REP(j,0,c) dp[0][j] = 0; dp[0][0] = 1;

    REP(i,1,n) REP(j,0,c){

        dp[i][j] = 0;

        REP(k,0,j) dp[i][j] += (cost[i][k] * dp[i-1][j-k]) % MOD;

        dp[i][j] %= MOD;

    }

    // print

    printf("%lld\n", dp[n][c]);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

const int maxn=410;

typedef long long ll;

int n,c;

const ll MOD=1e9+7;

ll a[maxn],b[maxn],f[maxn][maxn];

ll pwr[maxn][maxn],pre[maxn][maxn];

void preload()

{

    pre[0][0]=1;

    for(int i=1;i<=400;i++)

    {

        pwr[i][0]=1;

        for(int j=1;j<=400;j++)

        {

            pwr[i][j]=(pwr[i][j-1]%MOD*i)%MOD;

        }

    }

    for(int i=1;i<=400;i++)

    {

        pre[i][0]=1;

        for(int j=0;j<=400;j++)

        {

            pre[i][j]=(pwr[i][j]+pre[i-1][j])%MOD;

        }

    }

}

int main()

{

    preload();

    scanf("%d%d",&n,&c);

    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

    for(int i=1;i<=n;i++) scanf("%lld",&b[i]);

    f[0][0]=1;

    for(int i=1;i<=n;i++)

    {

        for(int j=0;j<=c;j++)

        {

            for(int k=0;k<=j;k++)

            {

                ll tmp=((pre[b[i]][k]-pre[a[i]-1][k])%MOD+MOD)%MOD;

                f[i][j]=(f[i][j]+f[i-1][j-k]*tmp)%MOD;

            }

        }

    }

    printf("%lld",f[n][c]);

}


// Fastest known solution for this problem: