#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=100000007;
ll n,k,s;
ll dp[5][15005];
ll sum[5][15005];
int main()
{
//freopen("out.txt","w",stdout);
//cin>>n>>k>>s;
int t=1;
scanf("%d",&t);
for(int tc=1;tc<=t;tc++){
scanf("%lld%lld%lld",&n,&k,&s);
//n=800,k=800,s=10000;
for(int i=1;i<=n;i++){
for(int j=0;j<i;j++){
sum[i%2+1][j]=0;
}
sum[i%2+1][i-1]=1;
for(int j=i;j<=i*k && j<=s;j++){
if(i%2==1){
sum[i%2+1][j]=(dp[i%2+1][j]%MOD+sum[i%2+1][j-1]%MOD)%MOD;
if(j>=k){
//if(j==7) cout<<sum[i%2+1][0]<<endl;
dp[i%2][j]=((sum[i%2+1][j-1]%MOD-sum[i%2+1][j-k-1]%MOD)+MOD)%MOD;
}else{
dp[i%2][j]=sum[i%2+1][j-1]%MOD;
}
//cout<<dp[i%2][j]<<' ';
}else{
//sum[i%2+1][j-1]=1;
sum[i%2+1][j]=(dp[i%2+1][j]%MOD+sum[i%2+1][j-1]%MOD)%MOD;
if(j>=k){
dp[i%2+2][j]=((sum[i%2+1][j-1]%MOD-sum[i%2+1][j-k-1]%MOD)+MOD)%MOD;
}else{
dp[i%2+2][j]=sum[i%2+1][j-1]%MOD;
}
//cout<<dp[i%2+2][j]<<' ';
}
}
//cout<<endl;
}
int indx;
if(n%2==0){
indx=2;
}else{
indx=1;
}
printf("Case %d: %lld\n",tc,dp[indx][s]);
memset(dp,0,sizeof dp);
}
}