#include <bits/stdc++.h>
#define VARNAME(x) #x

using namespace std;
using ll = long long;
using ld = long double;

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

ll power(const ll p, const ll n)
{
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 1) {
        return power(p, n - 1) * p % MOD;
    } else {
        const ll pp = power(p, n / 2);
        return pp * pp % MOD;
    }
}

ll inv(const ll p)
{
    return power(p, p - 2);
}
template <typename T, T mod = 924844033, T root = 5>
class NumberTheoreticTransformation
{
private:
    static T add(const T x, const T y) { return (x + y < mod) ? x + y : x + y - mod; }
    static T mul(const T x, const T y) { return (x * y) % mod; }
    static T power(T x, T n)
    {
        T res = 1;
        while (n > 0) {
            if (n & 1) {
                res = mul(res, x);
            }
            x = mul(x, x);
            n >>= 1;
        }
        return res;
    }
    static T inverse(const T x) { return power(x, mod - 2); }

public:
    NumberTheoreticTransformation() = delete;

    static void ntt(vector<T>& a, const bool rev = false)
    {
        const T size = a.size();
        const T height = (T)log2(2 * size - 1);
        for (T i = 0; i < size; i++) {
            T j = 0;
            for (T k = 0; k < height; k++) {
                j |= (i >> k & 1) << (height - 1 - k);
            }
            if (i < j) {
                swap(a[i], a[j]);
            }
        }
        for (T i = 1; i < size; i *= 2) {
            T w = power(root, (mod - 1) / (i * 2));
            if (rev) {
                w = inverse(w);
            }
            for (T j = 0; j < size; j += i * 2) {
                T wn = 1;
                for (T k = 0; k < i; k++) {
                    const T s = a[j + k + 0];
                    const T t = mul(a[j + k + i], wn);
                    a[j + k + 0] = add(s, t);
                    a[j + k + i] = add(s, mod - t);
                    wn = mul(wn, w);
                }
            }
        }
        if (rev) {
            const T v = inverse(size);
            for (T i = 0; i < size; i++) {
                a[i] = mul(a[i], v);
            }
        }
    }

    static vector<T> convolute(const vector<T>& a, const vector<T>& b)  // ans[i] = \sum_{A+B = i} a[A]*b[B]
    {
        const T size = a.size() + b.size() - 1;
        T t = 1;
        while (t < size) {
            t *= 2;
        }
        vector<T> A(t, 0), B(t, 0);
        for (T i = 0; i < a.size(); i++) {
            A[i] = a[i];
        }
        for (T i = 0; i < b.size(); i++) {
            B[i] = b[i];
        }
        ntt(A);
        ntt(B);
        for (T i = 0; i < t; i++) {
            A[i] = mul(A[i], B[i]);
        }
        ntt(A, true);
        A.resize(size);
        return A;
    }
};
template <typename T>
class GarnerNumberTheoreticTransformation
{
private:
    static constexpr T mod1 = 167772161;
    static constexpr T mod2 = 469762049;
    static constexpr T mod3 = 1224736769;
    static constexpr T mod1_inv_mod2 = 104391568;
    static constexpr T mod1mod2_inv_mod3 = 721017874;
    using NTT1 = NumberTheoreticTransformation<T, mod1, 3>;
    using NTT2 = NumberTheoreticTransformation<T, mod2, 3>;
    using NTT3 = NumberTheoreticTransformation<T, mod3, 3>;
    GarnerNumberTheoreticTransformation() = delete;

public:
    static vector<T> convolute(const vector<T>& a, const vector<T>& b, const T mod)  // ans[i] = \sum_{A+B = i} a[A]*b[B]
    {
        const auto x = NTT1::convolute(a, b);
        const auto y = NTT2::convolute(a, b);
        const auto z = NTT3::convolute(a, b);
        const int size = x.size();
        vector<T> ans(size);
        const T mod1mod2_mod = mod1 * mod2 % mod;
        for (int i = 0; i < size; i++) {
            T v1 = (y[i] - x[i]) * mod1_inv_mod2 % mod2;
            if (v1 < 0) {
                v1 += mod2;
            }
            T v2 = (z[i] - (x[i] + mod1 * v1) % mod3) * mod1mod2_inv_mod3 % mod3;
            if (v2 < 0) {
                v2 += mod3;
            }
            T c = (x[i] + mod1 * v1 + mod1mod2_mod * v2) % mod;
            if (c < 0) {
                c += mod;
            }
            ans[i] = c;
        }
        return ans;
    }
};


int main()
{
    ll N, C;
    cin >> N >> C;
    vector<ll> A(N);
    vector<ll> B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    vector<vector<ll>> sum(401, vector<ll>(401, 1));
    for (int i = 0; i <= 400; i++) {
        for (int j = 1; j <= 400; j++) {
            sum[i][j] = sum[i][j - 1] + power(j, i);
            sum[i][j] %= MOD;
        }
    }
    vector<vector<ll>> x(N, vector<ll>(401));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 400; j++) {
            x[i][j] = (sum[j][B[i]] - sum[j][A[i] - 1] + MOD) % MOD;
        }
    }
    using NTT = GarnerNumberTheoreticTransformation<ll>;
    vector<ll> ans = x[0];
    for (int i = 1; i < N; i++) {
        ans = NTT::convolute(ans, x[i], MOD);
        ans.resize(401);
    }
    cout << ans[C] << endl;

    return 0;
}


Measured memory_bytes: 2816