usingnamespacestd; usingnamespace FAST_IO; const ll mod = 1e9 + 7; constint INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; constdouble eps = 1e-5; constint maxn = 1e6 + 10; constint maxm = 1e5 + 10; int t; ll n, m, k; ll inv[maxn]; voidinit(int n) { inv[0] = inv[1] = 1; for (int i = 2; i <= n; i++) { inv[i] = (mod - mod / i) * inv[mod % i] % mod; // -k 写作了 p - k } } ll Cnm(ll n, ll m) { if (n < m) return0; if (n - m < m) m = n - m; ll a = 1; for (int i = 0; i < m; ++i) { a = a * (n - i) % mod * inv[i + 1] % mod; } return a; }
ll qpow(ll a, ll b) { ll ans = 1, tmp = a; while (b) { if (b & 1) ans = ans * tmp % mod; tmp = tmp * tmp % mod; b >>= 1; } return ans; } intmain() { // #define COMP_DATA #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); int tcase; read(tcase); init(1e6 + 1); while (tcase--) { read(n, m, k); ll ans = 0; ll cki = inv[k + 1]; for (int i = 0, flag = 1; i < k; ++i, flag = -flag) { cki = cki * (k - i + 1) % mod * inv[i] % mod; ans = (ans + flag * (k - i) * qpow(k - i - 1, n - 1) % mod * cki + mod) % mod; } ans = ans * Cnm(m, k) % mod; cout << ans << endl; } return0; }