##define INF 0x3f3f3f3f ##define lowbit(x) x & (-x) ##define mem(a, b) memset(a , b , sizeof(a)) ##define FOR(i, x, n) for(int i = x;i <= n; i++)
// const ll mod = 998244353; const ll mod = 1e9 + 7; // const double eps = 1e-6; // const double PI = acos(-1); // const double R = 0.57721566490153286060651209;
constint N = 1e6 + 10; ll f[N], invF[N];
ll quick_pow(ll a, ll b) { ll ans = 1; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans % mod; }
voidInit() { f[0] = f[1] = invF[0] = invF[1] = 1; for(int i = 2;i < N; i++){ f[i] = f[i - 1] * i % mod; } invF[N - 1] = quick_pow(f[N - 1], mod - 2); for(int i = N - 2;i >= 0; i--) { invF[i] = (invF[i + 1] * (i + 1)) % mod; }
}
ll C(ll m, ll n) { if(m < 0 n < 0 n > m) return0; ll ans = f[m]; ans = ans * invF[n] % mod; ans = ans * invF[m - n] % mod; return ans; }
ll rongchi(ll n, ll k) { int opt = 1; ll ans = 0; for(ll i = k;i >= 1; i--) { ll res = 1ll * opt * i * quick_pow(i - 1, n - 1) % mod * C(k, i) % mod; ans = (ans + res + mod) % mod; opt *= -1; } return (ans % mod + mod) % mod; }
voidsolve() { Init(); int _; scanf("%d",&_); int Case = 1; while(_--) { ll n, m, k; scanf("%lld%lld%lld",&n,&m,&k); ll ans = rongchi(n, k); for(ll i = m - k + 1;i <= m; i++) ans = ans * i % mod; ans = ans * invF[k] % mod; printf("Case ##%d: %lld\n",Case++,ans); } }
signed main() { ios_base::sync_with_stdio(false); //cin.tie(nullptr); //cout.tie(nullptr); ##ifdef FZT_ACM_LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); signed test_index_for_debug = 1; char acm_local_for_debug = 0; do { if (acm_local_for_debug == '$') exit(0); if (test_index_for_debug > 20) throw runtime_error("Check the stdin!!!"); auto start_clock_for_debug = clock(); solve(); auto end_clock_for_debug = clock(); cout << "Test " << test_index_for_debug << " successful" << endl; cerr << "Test " << test_index_for_debug++ << " Run Time: " << double(end_clock_for_debug - start_clock_for_debug) / CLOCKS_PER_SEC << "s" << endl; cout << "--------------------------------------------------" << endl; } while (cin >> acm_local_for_debug && cin.putback(acm_local_for_debug)); ##else solve(); ##endif return0; }