#include <bits/stdc++.h>
     
using namespace std;
     
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
    
const double PI = 3.141592653589793;
 
int ans = 0;

void solve(){
	ans = 0;
	int n, m;
	cin >> n >> m;
	int a[n];
	int c[n];
        vector <int> w;
        w.pb(0);
        int l[m+1];
        for(int i = 0; i <= m; i++)
            l[i] = 0;
	for(int i = 0; i < n; i++)
            cin >> a[i];
	for(int i = 0; i < n; i++)
            cin >> c[i];
	for(int i = 0; i < n; i++){
            for(int j = 0; j < c[i]; j++){
                vector <int> y;
                for(int q = 0; q < w.size(); q++){
                    if(w[q] + a[i] <= m and  l[w[q] + a[i]] == 0){
                        l[w[q] + a[i]] = 1;
                        y.pb(w[q] + a[i]);
                    }
                }
                for(int q = 0; q < y.size(); q++){
                    w.pb(y[q]);
                }
            }
            
        }
	ans = w.size() - 1;
}
int main() {
    fast;
    int t;
    cin >> t;
    for(int i = 0; i < t; i++){
        solve();
        cout << "Case " << i + 1 << ": " << ans << endl;
    }
    return 0;
}