// Original C++ solution (slower):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int mod=1e9+7;

const int maxn=410;

int n,c;

LL p1[maxn][maxn],p2[maxn][maxn],dp[maxn][maxn];

LL a[maxn],b[maxn];



void _init() {

    for (int i=1;i<=400;i++) {

        p1[i][0]=p2[i][0]=1;

        for (int j=1;j<=400;j++)

            p1[i][j]=(p1[i][j-1]*i)%mod;

    }

    for (int i=1;i<=400;i++)

        for (int j=0;j<=400;j++)

            p2[i][j]=(p2[i-1][j]+p1[i][j])%mod;

}



int main() {

    _init();

    while (scanf("%d%d",&n,&c)!=EOF) {

        for (int i=1;i<=n;i++) scanf("%lld",&a[i]);

        for (int i=1;i<=n;i++) scanf("%lld",&b[i]);

        dp[0][0]=1;

        for (int i=1;i<=n;i++)

            for (int j=0;j<=c;j++)

                for (int k=0;k<=j;k++) {

                    LL t=(p2[b[i]][k]-p2[a[i]-1][k]+mod)%mod;

                    dp[i][j]=(dp[i][j]+dp[i-1][j-k]*t)%mod;

                }



        printf("%lld\n", dp[n][c]);

    }

    return 0;

}


// Optimized solution to the same problem (faster):
//### In The Name Of GOD ###



#include <bits/stdc++.h>



using namespace std;



typedef long long ll ;



#define int ll

#define pb push_back

#define bp pop_back

#define pf push_front

#define fp pop_front

#define X first

#define Y second

#define IO ios_base::sync_with_stdio(false);

#define sz(a) (int)(a.size())



const int MOD = 1000000007;

const int INF = 30 * 1000 + 20;

const int MAXN = 401;

const int MLOG = 18;

const int NMAX = 60;



int dp[MAXN][MAXN];



signed main(){

	int n, C;

	cin >> n >> C;

	int A[n], B[n];

	for(int i = 0; i < n; i++)

		cin >> A[i];

	for(int i = 0; i < n; i++)

		cin >> B[i];

	dp[0][0] = 1;

	for(int i = 0; i < n; i++){

		int CC[C + 1] = {};

		for(int j = A[i]; j <= B[i]; j++){

			int x = 1;

			for(int k = 0; k <= C; k++){

				CC[k] += x;

				x *= j;

				CC[k] %= MOD;

				x %= MOD;

			}

		}

		for(int k = 0; k <= C; k++){

			//cout << "CC " << k << ' ' << CC[k] <<endl;

			for(int j = 0; j <= C; j++){

				if( j + k <= C ){

					dp[i + 1][j + k] += dp[i][j] * CC[k];

					dp[i + 1][j + k] %= MOD;

				}

			}

		}

	}

	cout << dp[n][C];

}	















































/*    ___           ___           ___           ___           ___           ___           ___          _____

     /__/\         /  /\         /__/\         /  /\         /__/\         /__/\         /  /\        /  /::\

    |  |::\       /  /::\        \  \:\       /  /::\       |  |::\       |  |::\       /  /::\      /  /:/\:\

    |  |:|:\     /  /:/\:\        \__\:\     /  /:/\:\      |  |:|:\      |  |:|:\     /  /:/\:\    /  /:/  \:\

  __|__|:|\:\   /  /:/  \:\   ___ /  /::\   /  /:/~/::\   __|__|:|\:\   __|__|:|\:\   /  /:/~/::\  /__/:/ \__\:|

 /__/::::| \:\ /__/:/ \__\:\ /__/\  /:/\:\ /__/:/ /:/\:\ /__/::::| \:\ /__/::::| \:\ /__/:/ /:/\:\ \  \:\ /  /:/

 \  \:\~~\__\/ \  \:\ /  /:/ \  \:\/:/__\/ \  \:\/:/__\/ \  \:\~~\__\/ \  \:\~~\__\/ \  \:\/:/__\/  \  \:\  /:/

  \  \:\        \  \:\  /:/   \  \::/       \  \::/       \  \:\        \  \:\        \  \::/        \  \:\/:/

   \  \:\        \  \:\/:/     \  \:\        \  \:\        \  \:\        \  \:\        \  \:\         \  \::/

    \  \:\        \  \::/       \  \:\        \  \:\        \  \:\        \  \:\        \  \:\         \__\/

     \__\/         \__\/         \__\/         \__\/         \__\/         \__\/         \__\/

      ___           ___                       ___

     /  /\         /__/\        ___          /__/\

    /  /::\       |  |::\      /  /\         \  \:\

   /  /:/\:\      |  |:|:\    /  /:/          \  \:\

  /  /:/~/::\   __|__|:|\:\  /__/::\      _____\__\:\

 /__/:/ /:/\:\ /__/::::| \:\ \__\/\:\__  /__/::::::::\

 \  \:\/:/__\/ \  \:\~~\__\/    \  \:\/\ \  \:\~~\~~\/

  \  \::/       \  \:\           \__\::/  \  \:\  ~~~

   \  \:\        \  \:\          /__/:/    \  \:\

    \  \:\        \  \:\         \__\/      \  \:\

     \__\/         \__\/                     \__\/

     _____          ___           ___           ___           ___

    /  /::\        /  /\         /  /\         /  /\         /  /\          ___       ___

   /  /:/\:\      /  /::\       /  /::\       /  /::\       /  /:/_        /  /\     /  /\

  /  /:/  \:\    /  /:/\:\     /  /:/\:\     /  /:/\:\     /  /:/ /\      /  /:/    /  /:/

 /__/:/ \__\:|  /  /:/  \:\   /  /:/~/:/    /  /:/  \:\   /  /:/ /::\    /  /:/    /__/::\

 \  \:\ /  /:/ /__/:/ \__\:\ /__/:/ /:/___ /__/:/ \__\:\ /__/:/ /:/\:\  /  /::\    \__\/\:\__

  \  \:\  /:/  \  \:\ /  /:/ \  \:\/:::::/ \  \:\ /  /:/ \  \:\/:/~/:/ /__/:/\:\      \  \:\/\

   \  \:\/:/    \  \:\  /:/   \  \::/~~~~   \  \:\  /:/   \  \::/ /:/  \__\/  \:\      \__\::/

    \  \::/      \  \:\/:/     \  \:\        \  \:\/:/     \__\/ /:/        \  \:\     /__/:/

     \__\/        \  \::/       \  \:\        \  \::/        /__/:/          \__\/     \__\/

                   \__\/         \__\/         \__\/         \__\/ 

                                      .;codddoc:'.

                                   .lkXWMMMMMMMWN0Oxc'

                                 .oXWMWXOdollox0NWMMWXx;.

                                :0WWWOc.       .'ldkNWWNO:.

                              .lXMWKl.              ,dXWWNk;  .:loxkkOkkxdl:'.

                             .lNMMK;                  'dXMWXd..oXMMMMMMMMMMWN0d;

                            :XMMX;                .':. ;0WMWO,.;oolcccclxOXWWMNk,

                            'OWMNl             .:dk0NWKc..dNWWXc           .l0WMMK:

                            oWMMk.          .:xKWMWWWXOc.  cKMMNl.           .xWMMK;

                           '0MMX: .loo:. .,dKWMMWKOx:'.     ;KMMNo.           .kWMWx.

                   ..;ldx, cNMMO' oXOc..cONMMWXx:...;dkxol:. ;KMMNl            lNMM0'

                'cd0XWWMK, dWMWx..;;.'oKWWWNkc. .lx0WMMMMWW0, ;KMMXc           :NMM0'

             .ckXWMMWXOd:..kWMWo   ,dXMWWKo,    ...';:loxO0XO, :XWMK;          lWMMO.

           .l0WMWNOo;.    .OMXd. ,xNMMW0c.                ..,.  oNMWO. :dl,.  .kWMWd.

          'OWMWXo'        'Ok,.'dNMMWO:.                        .xWMWo..OWWO' :XMMX:

         'OWMWk'          .'..lKWMW0c.            .              ,0MMK; ;0Nx..OMMWx.

         oWMWk.             ;OWWWKl.        .:oxO000Oxl;.         lNMWk. .,..dWMM0,

        .kMMNl            'xNMWNx'        'dKWMMMMMMMWMW0l.       .OMMNc   .oNWMXc ,d;

        .xMMWo           :KWMW0:.        :KMMWMMMMMMMMMMMWO,       lWMMO. .oNMMNl '0WNk,

         cNMMK;        .oNMMNx.         ,KMMMMMMMMMMMMMMMMMO.      ,KMMX: ;KMMNl. 'OWWMXo.

         .dWWWK;      .kWMMKc.'d;       oWMMMMMMMMMMMMMMMMMN:      .xWWWd.'0MXl    .lXMWWx.

          .dNMMNd.   'OWMW0;.;KWd       lNMMMMMMMMMMMMMMMMMX;       cNMM0'.x0:       ;0WMWx.

            :0WMW0l. ,kNWO' ;KMM0'      .OWWMMMMMMMMMWWWWWWx.       ,KMMX; '.         ;KMMNc

             .dXWWWKo'.,:.  '0MMWl       'kNMMMMMMMMMWWWWNd.        .OMMWl            .xMMMx.

               'oKWMMNkc'    lNWM0'       .:kXWMMMMMMWNKd,          .xMMMd.           .xMMMx.

                 .cONMMWXOl,..;okKl          .;coooolc,.         ;o' dWMMk.           :XMMN:

                 ...,o0NWWWW0xc,.'.                            ,kNK, oWMMk.         .lXMMWd.

                .dKd;..,lkXWMWMNKko:'.                       ;kNWM0' dMMMk.       'l0WWWXo.

                ,KWMX:    .;oOXWMMMWNKkdl:'..              .oOKK0x; .xMMMk.  .':oOXWMWXx,

                :NWW0,        .,cdOKNWMMMWNX0kxolc::,'......''....  .kMMMd 'xKNWMMWXkl'

                cNMM0'            .,,:ldk0XNWMMMMMWWWNXXKK0000OOOOc ,KMMNc cNMNKOd:'

                ;XMMK;            ;kkoc,...';codxO00KXXNNWMMMMMWWX: cNMMK, ,l:,.

                .OMMWx.            cXMMXo.   ..,,''''''',;;::::::;..kMMWx.

                 :XMWNx.            :XWWNx. .xXNNXK0d;.            cNMMX:

                  :KWWWKo;..      .  ;OWWW0:.,kKOoc;.             ,0MMWd.

                   'dXWMMWX0kxxxxO0O:..xNWWNx'...                'OWMWO.

                     .cx0XWWMMMMMMWWKc..:0WWWXd'                ,OWMWO,

                        ..,:cllllc:;'.   .oXWMWXd;..          'oXMMWO'

                                           'oKWWMNX0dc,'...,cxXWMWXo.

                                             .:kXWWWMMWNXXXWWMMWXd'

                                                .:cok0XNWWWNKOdc.

                                                     ..',,,'.

*/

// Fastest known solution for this problem: