using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static long factMax = 2000;//nCkにおけるnの最大値
static long[] factorials = new long[factMax+1];//i!(mod p)をO(n)で先にメモ。
static long[] factorialRs = new long[factMax+1];//i!^-1(mod p), pは素数でO(n)。

	static void Main()
	{
    long mod = 1000000007;
    long answer = 0;
    factorials[0] = 1;
    factorialRs[factMax] = DivideModFactorial(factMax,mod);
    for(long i = 1; i <= factMax; i++)
    {
      factorials[i] = (factorials[i-1]*i)%mod;//i!(mod)
      factorialRs[factMax-i] = (factorialRs[factMax+1-i]*(factMax+1-i))%mod;//逆元も先にメモ
    }
  
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int c = int.Parse(input[1]);
    long[,] dp = new long[n+1,c+1];//n個見てc個配った
		long[] numsA = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] numsB = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[,] pows = new long[401,401];//aのb乗
    for(long i = 1; i <= 400; i++)
    {
      long powMemo = 1;
      for(int j = 0; j <= 400; j++)
      {
        pows[(int)i,j] = powMemo;
        powMemo *= i;
        powMemo %= mod;
      }
    }

    long[,] xPows = new long[401,401];//1^a +2^a +b^a
    for(int i = 0; i <= 400; i++)
    {
      long powMemo = 0;
      for(int j = 0; j <= 400; j++)
      {
        xPows[i,j] = powMemo;
        powMemo += DivideMod(j+1,i,mod);
        powMemo %= mod; 
      }
    }

    for(int i = 0; i <= c; i++) dp[0,0] = 1;
    
    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j <= c; j++)
      {
        for(int k = 0; k <= 400; k++)
        {
          long multiMemo = xPows[k,numsB[i-1]]-xPows[k,numsA[i-1]-1];
          multiMemo %= mod;
          if(multiMemo < 0) multiMemo += mod;
          
          if(j-k >= 0) dp[i,j] += dp[i-1,j-k]*multiMemo;
          dp[i,j] %= mod;
        }
        //Console.WriteLine(i+" "+j+" "+dp[i,j]);
      }
    }

		Console.WriteLine(dp[n,c]);
	}

  static long MathPow(long x, long a)//戻り値はx^a。O(loga)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x;
  
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
      }
    memo *= memo;
    num *= 2;
    }
    return answer;
  }

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)。O(loga)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数。O(logp)
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long ModFactorial(long x, long p)//戻り値はx!(mod p)
  {
    long answer = 1;
    for(int i = 2; i <= x; i++)
    {
      answer *= i;
      answer %= p;
    }
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }
  
}

Measured memory_bytes: 14560