// Slower C++ solution:
/*  ***  In The Name of God ... ***  */ 

#include <bits/stdc++.h>

 

using namespace std;

 

typedef long long ll;

typedef long double ld;

 

 

#define int long long

#define all(v) v.begin() , v.end()



template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}

template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}



const int N = 400 + 10 , mod = 1e9 + 7 ;



int n , C , a [ N ] , b [ N ] , t [ N ] [ N ] , sum [ N ] [ N ] , dp [ N ] [ N ] ; 



int32_t main()

{

	//ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n >> C ;

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

		cin >> a [ i ] ;

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

		cin >> b [ i ] ;

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

		t [ i ] [ 0 ] = 1 ;

		for ( int j = 1 ; j < N ; ++ j ) {

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

		}

	}

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

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

			for ( int k = a [ i ] ; k <= b [ i ] ; ++ k )

				sum [ i ] [ j ] += t [ k ] [ j ] , sum [ i ] [ j ] %= mod ; 

		}

	}

	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 ) {

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

				dp [ i ] [ j ] %= mod ; 

			}

		}

	}/*

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

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

			cout << i << ' ' << want << ' ' << dp [ i ] [ want ] << '\n' ; 

		}

		}*/

	cout << dp [ n ] [ C ] % mod << '\n' ; 

}


// Faster C++ solution for the same problem (measured speedup: 2.334627976250162x):
//### 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.

                                                     ..',,,'.

*/