#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define ll long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define vp vector<pair<int,int>> 
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define mod 1000000007
#define inf 1e18
#define w(x)  \
int x;    \
cin >> x; \
while (x--)
#define bakchodi                  \
   ios_base::sync_with_stdio(0); \
cin.tie(0);                   \
cout.tie(0)

//prime sieve
vector<bool> primes(100006, false);
void sieve()
{
   for (ll i = 3; i <= 100006; i += 2)
   {
      primes[i] = 1;
  }
    //Sieve
  for (ll i = 3; i <= 100006; i+=2)
  {
      if (primes[i] == 1)
      {
         for (ll j = i * i; j <= 100006; j += i)
         {
            primes[j] = 0;
        }
    }
}
primes[2] = 1;
primes[0] = primes[1] = 0;

}

int recpow(int x, int n)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x), n / 2);
    else //n is odd
        return (x * recpow((x * x), (n - 1) / 2));
}

int main()
{
    bakchodi;
    w(x)
    {
     int n,k;
     cin>>n>>k;

  ll ans=1;
    for(int i=1;i<=k;i++)
        ans=(1LL*n*ans)%mod;


     cout<<ans<<endl;
     
 }

}

