#include<bits/stdc++.h>
using namespace std;
const int N=100+50;
const int mod=1e9+7;


using ll=long long;
int read(){
    int k=0,sig=1;
    char c=getchar();
    while(!isdigit(c)){
        if(c=='-') sig*=-1;
        c=getchar();
    }
    while(isdigit(c)){
        k=(k<<3)+(k<<1)+c-'0';
        c=getchar();

    }
    return k*sig;
}

int a[N];
int main() {
    int t=read();
    while(t--) {
        int n=read(),k=read();
        ll ans=1;
        for(int i=1;i<=k;i++) ans=ans*n%mod;
        printf("%lld\n",ans);
    }
}
