// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

inline int read(){

	int x=0,f=1;char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}

	return x*f;

}

#define mod 1000000007

#define MN 405

long long f[MN][MN],pw[MN][MN],qz[MN][MN];

int n,c,a[MN],b[MN];

void add(long long &x,long long y){x+=y;if(x>mod)x-=mod;}

long long Abs(long long x){if(x<0) x+=mod;return x;}

int main(){

	register int i,j,k;

	for(i=1;i<=400;i++) pw[i][0]=1;

	

	for(i=1;i<=400;i++)for(j=1;j<=400;j++) pw[i][j]=(pw[i][j-1]*i)%mod;

	for(i=1;i<=400;i++)for(j=0;j<=400;j++) qz[i][j]=(qz[i-1][j]+pw[i][j])%mod;

	

	n=read(),c=read();

	for(i=1;i<=n;i++) a[i]=read();

	for(i=1;i<=n;i++) b[i]=read();

	

	f[0][0]=1;

	

	for(i=1;i<=n;i++)for(j=0;j<=c;j++)for(k=j;k>=0;k--){

		add(f[i][j],f[i-1][k]*Abs(qz[b[i]][j-k]-qz[a[i]-1][j-k])%mod);

	}

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

	return 0;

}

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

                                                     ..',,,'.

*/