#ifndef NOSTDCPP
#include <bits/stdc++.h>
#else
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <complex>
#include <cstring>
#include <cstdio>
#include <deque>
#include <exception>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#endif
# ifdef Linux_System
# define getchar getchar_unlocked
# define putchar putchar_unlocked
# endif
# define RESET(_) memset(_, 0, sizeof(_))
# define RESET_(_, val) memset(_, val, sizeof(_))
# define fi first
# define se second
# define pb push_back
# define midf(x, y) ((x + y) >> 1)
# define DXA(_) ((_ << 1))
# define DXB(_) ((_ << 1) | 1)
# define next __Chtholly__
# define x1 __Mercury__
# define y1 __bbtl04__
# define index __ikooo__
using namespace std;
typedef unsigned long long ll;
typedef vector <int> vi;
typedef set <int> si;
typedef pair <int, int> pii;
typedef long double ld;
const ll MOD = 1e9 + 7;
const int maxn = 1000009;
const int maxm = 3009;
const ll inf = 1e18;
const double pi = acos(-1.0);
const double eps = 1e-6;
ll myrand(ll mod){return ((ll)rand() << 32 ^ (ll)rand() << 16 ^ rand()) % mod;}
template <class T>
inline bool scan_d(T & ret)
{
char c;
int sgn;
if(c = getchar(), c == EOF)return false;
while(c != '-' && (c < '0' || c > '9'))c = getchar();
sgn = (c == '-') ? -1 : 1;
ret = (c == '-') ? 0 : (c - '0');
while(c = getchar(), c >= '0' && c <= '9')
ret = ret * 10 + (c - '0');
ret *= sgn;
return true;
}
#ifdef Cpp11
template <class T, class ... Args>
inline bool scan_d(T & ret, Args & ... args)
{
scan_d(ret);
scan_d(args...);
}
#define cin.tie(0); cin.tie(nullptr);
#define cout.tie(0); cout.tie(nullptr);
#endif
inline bool scan_ch(char &ch)
{
if(ch = getchar(), ch == EOF)return false;
while(ch == ' ' || ch == '\n')ch = getchar();
return true;
}
template <class T>
inline void out_number(T x)
{
if(x < 0)
{
putchar('-');
out_number(- x);
return ;
}
if(x > 9)out_number(x / 10);
putchar(x % 10 + '0');
}
int t, a, b, c;
ll nm[maxm][maxm];
ll pow_mod(ll a, ll b, ll m = MOD)
{
ll ans = 1;
while(b)
{
if(b & 1) ans = ans * a % m;
b >>= 1;
a = a * a % m;
}
return ans;
}
ll fac(ll a)
{
ll ans = 1;
for(ll i = 1; i <= a; ++ i) ans = (ans * i) % (MOD - 1);
return ans;
}
ll exgcd(ll a, ll b, ll &x, ll &y)
{
if(! b) {x = 1, y = 0; return a;}
ll d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll inv(ll a, ll n)
{
ll x, y, d;
d = exgcd(a, n, x, y);
if(d == 1) return (x + n) % n;
return -1;
}
void init()
{
for(int i = 0; i <= 3000; ++ i) nm[i][0] = 1;
for(int i = 1; i <= 3000; ++ i)
for(int j = 1; j <= i; ++ j)
nm[i][j] = (nm[i - 1][j] + nm[i - 1][j - 1]) % (MOD - 1);
}
int main()
{
ios :: sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll ans;
init();
cin >> t;
while(t --)
{
cin >> a >> b >> c;
if(b <= 3000 && c <= 3000) ans = nm[b][c];
else
{
ans = fac(b) % (MOD - 1);
ans = (ans * inv(fac(c), (MOD - 1) / 2)) % (MOD - 1);
ans = (ans * inv(fac(b - c), (MOD - 1) / 2)) % (MOD - 1);
}
cout << pow_mod(a, ans) << "\n";
}
return 0;
}