#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
T inverse(T a, T m) {
  T u = 0, v = 1;
  while (a != 0) {
    T t = m / a;
    m -= t * a; std::swap(a, m);
    u -= t * v; std::swap(u, v);
  }
  assert(m == 1);
  return u;
}
template <typename T>
class modular {
  private:
    int value;
  public:
    constexpr modular() = default;
    constexpr modular(const modular&) = default;
    constexpr modular(modular&&) = default;
    modular& operator=(const modular&) = default;
    modular& operator=(modular&&) = default;

    template <typename U>
    constexpr modular (const U& x) {value = normalize(x);}

    template <typename U>
    static auto normalize(const U& x) {
      int v = static_cast<int>(-mod() <= x && x < mod() ? x : x % mod());
      if (v < 0) v += mod();
      return v;
    }

    auto const& operator()() const { return value; }
    template <typename U>
    explicit operator U() const { return static_cast<U>(value); }
    constexpr static auto mod() { return T::value; }

    auto& operator+=(const modular& other) {
      if ((value += other.value) >= mod()) value -= mod();
      return *this;
    }
    auto& operator-=(const modular& other) {
      if ((value -= other.value) < 0) value += mod();
      return *this;
    }
    template <typename U>
    auto& operator+=(const U& other) {return *this += modular(other); }
    template <typename U>
    auto& operator-=(const U& other) {return *this -= modular(other); }
    auto operator-() const { return modular(-value); }
    auto& operator++() {return *this += 1;}
    auto& operator--() {return *this -= 1;}
    auto  operator++(int) {modular result(*this); operator++(); return result;}
    auto  operator--(int) {modular result(*this); operator--(); return result;}

    template <typename U = T>
    auto& operator*=(const modular& rhs) {
      value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value));
      return *this;
    }
    auto& operator/=(const modular& other) {
      return *this *= modular(inverse(other.value, mod()));
    }
};
template <typename T> struct is_modular : std::false_type {};
template <typename T> struct is_modular <modular<T>> : std::true_type{};
template <typename T> constexpr bool is_modular_v = is_modular<T>::value;

template <typename T> bool operator==(const modular<T>& lhs, const modular<T>& rhs) { return lhs.value == rhs.value; }
template <typename T, typename U> bool operator==(const modular<T>& lhs, U rhs) { return lhs == modular<T>(rhs); }
template <typename T, typename U> bool operator==(U lhs, const modular<T>& rhs) { return modular<T>(lhs) == rhs; }

template <typename T> bool operator!=(const modular<T>& lhs, const modular<T>& rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(const modular<T>& lhs, U rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(U lhs, const modular<T>& rhs) { return !(lhs == rhs); }

template <typename T> modular<T> operator+(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(const modular<T>& lhs, U rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(U lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }

template <typename T> modular<T> operator-(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(const modular<T>& lhs, U rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(U lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }

template <typename T> modular<T> operator*(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(const modular<T>& lhs, U rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(U lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }

template <typename T> modular<T> operator/(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(const modular<T>& lhs, U rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(U lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }

template<typename T, typename U>
modular<T> power (const modular<T>& a, U b) {
  assert(b >= 0);
  modular<T> x = a, ret = 1;
  for (; b > 0; b /= 2) {
    if (b % 2 == 1) ret *= x;
    x *= x;
  }
  return ret;
}

template <typename T>
std::string to_string(const modular<T>& a) {
  return std::to_string(a());
}
template <typename T>
auto operator<<(std::ostream& os, const T& a)
  -> std::enable_if_t<is_modular_v<T>, std::ostream&>{
    return os << a();
  }
template <typename T>
auto operator>>(std::istream& is, T& a)
  -> std::enable_if_t<is_modular_v<T>, std::istream&> {
  long long x; is >> x;
  a = T(x);
  return is;
}


using mod_type = int;

struct voriable_mod { static mod_type value; };
mod_type voriable_mod::value;
// mod_type& md = voriable_mod::value;
// using Mint = Modular<voriable_mod>;


constexpr int md = 1'000'000'007;
using mint = modular<std::integral_constant<std::decay_t<decltype(md)>, md>>;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

template < typename Semiring, int Length >
class polynominal {
    using Value = typename Semiring::type;
    std::vector<Value> storage;

  public:
    constexpr polynominal()=default;
    constexpr polynominal(const polynominal&)=default;
    constexpr polynominal(polynominal&&)=default;
    polynominal& operator=(const polynominal&)=default;
    polynominal& operator=(polynominal&&)=default;

    polynominal(int n, Value val) : storage(n, val){}
    polynominal(int n) : storage(n, zero()){}
    polynominal(std::initializer_list< Value > il) : storage(il){}

    static auto id()   { return polynominal{Semiring::id()}; }
    static auto zero() { return polynominal{};               }

    auto&       at    (size_t i)       { return storage.at(i); }
    auto const& at    (size_t i) const { return storage.at(i); }
    auto        degree()         const { return storage.empty() ? -1 : (int)storage.size() - 1; }

    auto& operator*=(polynominal< Semiring, Length> const& rhs) {
      int m = degree();
      int n = rhs.degree();
      if (m == -1 || n == -1) return *this = zero();
      auto ret = std::vector<Value>(std::min(n + m + 1, Length), 0);
      for (auto i = 0; i <= m; i++) {
        for (auto j = 0; j <= n && i + j < Length; j++) {
          ret.at(i + j) += at(i) * rhs.at(j);
        }
      }
      storage.swap(ret);
      return *this;
    }

    auto operator()(){return storage;}

    template < typename Semiring_, int Length_ >
    friend std::ostream& operator<<(std::ostream& os, polynominal< Semiring_, Length_ > p);
};

template < typename Semiring, int Length > auto operator*(const polynominal< Semiring, Length >& lhs, const polynominal< Semiring, Length > rhs) { return lhs *= rhs; }
template < typename Semiring, int Length > auto operator*(const polynominal< Semiring, Length >& lhs, typename Semiring::Value rhs) { return lhs *= polynominal< Semiring, Length >{rhs}; }
template < typename Semiring, int Length > auto operator*(typename Semiring::Value lhs, const polynominal< Semiring, Length >& rhs) { return polynominal< Semiring, Length >{lhs} *= rhs; }

template < typename Semiring, int Length > std::ostream& operator<<(std::ostream& os, polynominal< Semiring, Length> p) { return os << p(); }

struct mint_semiring {
  using type = mint;
  static constexpr auto id()   { return mint(1); }
  static constexpr auto zero() { return mint(0); }
};

using poly = polynominal<mint_semiring, 401>;

constexpr int max = 400;
mint memo[max + 1][max + 1];
bool ckd[max + 1][max + 1];
auto sum(int k, int p) {
  assert(0 <= k && k <= max);
  assert(0 <= p && p <= max);
  if (ckd[k][p]) return memo[k][p];
  auto& ret = memo[k][p];
  ret = k > 0 ? sum(k - 1, p) + power(mint(k), p) : (k == p);
  ckd[k][p] = true;
  return ret;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, c; std::cin >> n >> c;
  std::vector<int> a(n), b(n); std::cin>> a >> b;
  auto ret = poly::id();
  rep(i, 0, n) {
    auto now = poly(c + 1, 0);
    rep(p, 0, c + 1) {
      now.at(p) = sum(b.at(i), p) - sum(a.at(i) - 1, p);
    }
    ret *= now;
  }
  std::cout << ret.at(c) << std::endl;
  return 0;
}

Measured memory_bytes: 1024