#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1)
#define MAX	300
#define MX 100000
#define vs    vector<string>
#define pi 3.14159265358979323846

const int xx = 1e9+7;




ll tow(ll a, ll b)
{
    ll ans = 1;
    for (int i = 0; i < b; i++)
    {
        ans *= a;
    }
    return ans;
}

ll gcd ( ll a, ll b )
{

    if(b==0)return a;
    return gcd(b,a%b);
}

ll lcm(ll a, ll b)
{
    return (a/gcd(a,b))*b;
}
#define pii pair<int,int>

bool isPerfectSquare(long double x)
{

    if (x >= 0) {

        long long sr = sqrt(x);

        return (sr * sr == x);
    }
    return false;
}

int main()
{
       char c1,c2;
       ll b1,b2,n,k;
      T
       {
           cin>>n>>k;

           ll ans=1;
         while(k--)
         {
             ans*=n;
             ans%=xx;
         }

         cout<<ans<<endl;

        }

    }
