#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define sti stack<int>
#define stkl stack<ll>
#define qi queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll mod=1e9+7;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

using namespace std;
int c=0;
 
ll pow(ll a,ll b){
	ll ans=1;
	if(b==0)
		return 1;
	ans*=pow(a,b/2);
	ans=((ans%mod)*(ans%mod))%mod;
	if(b&1){
		ans=((ans%mod)*a);
		ans%=mod;
	}
	return ans%mod;
}
 
ll gcd(ll a,ll b){
	if(b==0)
		return a;
	return gcd(b,a%b);
}
 
vll fac(1e6+5,-1);
ll fact(ll n){
	if(n<=1)
		return fac[n]=1ll;
	if(fac[n]>0)
		return fac[n];
 
	fac[n]=n*fact(n-1);
	fac[n]%=mod;
	return fac[n];
}
ll nCr(ll n,ll r){
	if(n==r||r==0)
		return 1;
	ll ans=fac[n];
	ans*=pow(fac[n-r],mod-2);
	ans%=mod;
	ans*=pow(fac[r],mod-2);
	ans%=mod;
	return ans;
}
 
const ll nax=1e5+3;

si sq;

void solve(){
	ll n,k;
	cin>>n>>k;
	cout<<(ll)pow(n,k)<<endl;



	// cout<<"Case #"<<c<<": "<<prime[prime.size()-1];
}

int main(){
    IOS; 
    // sieve();
	int q=1;
	cin>>q; 

	for(int i=0;i<=1e4;i++)
		sq.insert(i*i);
	while(q--){
		c++;
		solve();
	}
}
