#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) typedef long long ll; using namespace std; #define doublecout(a) cout< 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); ll t; cin >> t; while(t--){ ll x, k; cin >> x >> k; mod = 1000000006; k = modpow(k, mod / 2 - 2); mod++; cout << modpow(x, k) << endl; } return 0; }