#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <climits>
#include <queue>
#define ll long long
using namespace std;
const int MOD = 1e8+7;
int dp[55][1010];
void solve()
{
int n,k,w[1005],cnt[1005];
scanf("%d %d",&n,&k);
memset(dp,0,sizeof(dp));
for(int i = 1; i <= n; i++)
scanf("%d",&w[i]);
for(int i = 1; i <= n ;i++)
scanf("%d",&cnt[i]);
dp[0][0] = 1;
for(int i = 1; i <= n; i++)
{
for(int j = 0; j <= cnt[i]; j++)
for(int m = j*w[i]; m <= k; m++)
dp[i][m] = (dp[i][m]+dp[i-1][m - j*w[i]])%MOD;
}
printf("%d\n",dp[n][k]);
}
int main(void)
{
int t,cnt = 0;
scanf("%d",&t);
while(t--)
{
printf("Case %d: ",++cnt);
solve();
}
return 0;
}