local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local n, c = io.read("*n", "*n")
local a, b = {}, {}
for i = 1, n do
  a[i] = io.read("*n")
end
for i = 1, n do
  b[i] = io.read("*n")
end
local dp1, dp2 = {1}, {0}
for i = 2, c + 1 do
  dp1[i] = 0
  dp2[i] = 0
end
for i = 1, n do
  local t = {}
  local ai, bi = a[i], b[i]
  for j = ai, bi do
    t[j + 1 - ai] = 1
  end
  local dpadd = {}
  for j = 1, c + 1 do
    dpadd[j] = 0
  end
  for j = 1, c + 1 do
    local tmp = 0
    for k = ai, bi do
      tmp = badd(tmp, t[k + 1 - ai])
      t[k + 1 - ai] = bmul(t[k + 1 - ai], k)
    end
    dpadd[j] = tmp
  end
  local dpsrc = i % 2 == 1 and dp1 or dp2
  local dpdst = i % 2 == 1 and dp2 or dp1
  for j = 1, c + 1 do
    dpdst[j] = 0
  end
  for j = c + 1, 1, -1 do
    local dpj = dpsrc[j]
    for k = 1, c - j + 2 do
      local dst = j + k - 1
      dpdst[dst] = badd(dpdst[dst], bmul(dpj, dpadd[k]))
    end
  end
end
if n % 2 == 0 then
  print(dp1[c + 1])
else
  print(dp2[c + 1])
end
