/*****************************
      *   Mahfuz   *
   * Created: 20.04.2021 *
*****************************/

#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
#define ll long long
#define ld long double
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define nl '\n'
#define mod 1000000007

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

ll int fastExp(ll int n)
{
    ll int res = 1;
    ll int a = 2;

    while(n)
    {
        if(n%2)
        {
            res*=a;
            n--;
        }

        a*=a;
        n/=2;
    }

    return res;
}


int main()
{
    FIO;
    int t;
    ll int n, k, a, s, d, i;

    cin >> t;

    while(t--)
    {
        cin >> n >> k;

        s = 1;
        for(i=0; i<k; i++)s = (s*n)%mod;

        //s = (s*k)%mod;
        cout << s << nl;
    }

    return 0;
}