#include #include #include #include #include using namespace std; const int MOD = 1e9 + 7; long long repow(long long x, long long y, int mod){ if(y == 0) return 1; long long res = 1; while(y != 0){ if(y & 1) res = res * x % mod; x = x * x % mod; y >>= 1; } return res; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int testcase; cin >> testcase; int tempmod = (MOD - 1) / 2 - 2; while(testcase--){ long long X, K; cin >> X >> K; long long l = repow(K, tempmod, MOD - 1); long long ans = repow(X, l, MOD); cout << ans << endl; } }