题目传送门
#include
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 7;
const int mod = 1e9 + 7;
ll q_pow(ll a, ll b, ll mod) { // 快速幂
ll res = 1LL;
while (b) {
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res % mod;
}
ll inv(ll x) {
return q_pow(x, mod - 2, mod);
}
ll factorial[MAXN] = { 1 }; // 阶乘
inline ll C(ll n, ll k) {
return factorial[n] * inv(factorial[n - k] * factorial[k]%mod) % mod;
}
int main() {
std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
factorial[0] = 1;
for (int i = 1; i <= MAXN - 7; ++i)
factorial[i] = factorial[i - 1] * i % mod;;
int t; cin >> t;
while (t--) {
ll n, m, k; cin >> n >> m >> k;
if (k + m > n) {
cout << 0 << endl;
continue;
}
ll a = C(n, k), b = q_pow(2, n, mod);
for (int i = 0; i < m; ++i)
b = (b - C(n, i) + mod) % mod;
cout << a * inv(b) % mod << endl;
}
}