#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define lg 1000000000
#define vec vector<int>
void arrInput(int a[],int n){rep(i,0,n) cin>>a[i];}

void solve()
{
  ll n,k,mod=1e9+7,ans=1;
  cin>>n>>k;
  rep(i,0,k) ans=(ans*n)%mod;
  cout<<ans<<endl;
}

int main()
{
  test() solve();
}