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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i < (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do{ cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << setprecision(20);
    }
} iosetup;

// YOUR CODE GOES HERE ↓↓↓
template<const long long mod = 1000000007>
struct Modint{ //modint
    long long x;
    Modint(long long x = 0): x((x %= mod) < 0 ? x + mod : x) {}
    friend istream& operator >> (istream &s, Modint& m){ return s >> m.x; }
    friend ostream& operator << (ostream &s, Modint m){ return s << m.x; }
    inline Modint& operator += (Modint a){ if((x += a.x) >= mod)x -= mod; return *this; }
    inline Modint& operator -= (Modint a){ if((x += mod - a.x) >= mod)x -= mod; return *this; }
    inline Modint& operator *= (Modint a){ (x *= a.x) %= mod; return *this; }
    inline Modint& operator /= (Modint a){ return (*this) *= a.inv(); }
    inline Modint operator + (Modint a){ Modint res(*this); return res += a; }
    inline Modint operator - (Modint a){ Modint res(*this); return res -= a; }
    inline Modint operator * (Modint a){ Modint res(*this); return res *= a; }
    inline Modint operator / (Modint a){ Modint res(*this); return res /= a; }
    inline void takemod(){ x = ((x % mod) + mod) % mod; }
    inline Modint inv(){
        long long a = x, b = mod, u = 1, v = 0, t;
        while(b){
            t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return Modint(u);
    }
    inline Modint pow(long long p){
        Modint res(1), tmp(x);
        for(; p; p >>= 1){ if(p & 1)res *= tmp; tmp *= tmp; }
        return res;
    }
};

using mint = Modint<>;
const int not_found = 404;
int N, C;
int a[not_found], b[not_found];
mint dp[not_found][not_found];
mint now[not_found], use[not_found];

void calc(int sz){

};

int main(){

    cin >> N >> C;
    rep(i, N)cin >> a[i];
    rep(i, N)cin >> b[i];
    dp[0][0] = mint(1);
    rep(i, N){
        int sz = b[i] - a[i] + 1;
        rep(j, sz){
            now[j] = mint(1);
            use[j] = mint(a[i] + j);
        }
        rep(j, C + 1){
            mint cur(0);
            rep(k, sz){
                cur += now[k];
                now[k] *= use[k];
            }
            rep(k, C - j + 1){
                dp[i + 1][k + j] += cur * dp[i][k];
            }
        }
    }

    cout << dp[N][C] << endl;
    return 0;
    
}

Measured memory_bytes: 1536