#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int const maxn = 110,mod = 1e9+7;
int T,n,k;
ll f[22],g[22];
ll p[100010];


void dfs(int x,int start,int now){
	if(now == x){
		g[x]++;
		g[x] %= mod;
		return;
	}
	if(now > x) return ;
	for(int i = 1;i<=start;i++){
		dfs(x,i,now+i);
	}
}

void init(){
	p[0] = 1;
	for(int i = 1;i <= 100005;i++){
		p[i] = (p[i-1]*i)%mod;
	}
	for(int i = 1;i <= 20;i++){
		dfs(i,i,0);
	}
}

int main(){
	f[0] = 1;
	init();
	//cout<<g[7]<<endl;
	for(int i = 1;i <= 21;i++) f[i] = 2*f[i-1];
	cin>>T;
	while(T--){
		cin>>n>>k;
		long long ans = 1;
		if(n == 1){
			cout<<1<<endl;
			continue;
		}
		for(int i = 1;i <= k;i++){
			ans *= n;
			ans %= mod;
		}
		cout<<ans<<endl;
	} 
	return 0;
}
