/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
Do not pray for an easy life, pray for the strength to endure a difficult one.
When something is important enough, you do it even if the odds are not in your favor.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.
No matter how hard it gets, NEVER GIVE UP*/

#include <bits/stdc++.h>

#define pb push_back
#define MP make_pair
#define ALL(r) (r).begin(),(r).end()
#define pi 1000000007
#define M 1000000007

typedef long long int ll;

#define FOR(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; ++i )
#define FORN(i,m,n) for(ll i=(ll)(m-1) ; i >= (ll) (n) ; --i )

#define RUN_FAST ios::sync_with_stdio(false);

using namespace std;

ll F[1000005];

ll bmd(ll n, ll k)
{
    if (!k)
        return 1;
    if (k % 2)
        return (n * bmd(n, k - 1)) % M;
    ll R = bmd(n, k / 2);
    return (R * R) % M;
}

ll m_inv(ll x)
{
    return bmd(x, M - 2);
}

ll ncr(ll n, ll r)
{
    return F[n] * m_inv(F[r] * F[n - r] % M) % M;
}

ll npr(ll n, ll r)
{
    return ncr(n, r) * F[r];
}



void solve()
{
    ll a, b, c, d, m, n, p, q, r, x, y, z, aa, bb, cc, dd; //variable
    double pp, qq, rr, xx, yy, zz;
    char ch1, ch2, ch3, ch4, ch5;
    ll i, j, k, l; //pointer
    ll cnt = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0, sum = 0, sum2 = 0, mx = LLONG_MIN, mn = LLONG_MAX; //counter
    ll flag = 0, flag2 = 0; //flag
    vector <ll> vec1, vec2, vec3;
    string s1, s2, s3;

    //PULOK SAHA
    //BMO

    //Main Code
    //***************************************************************************

    cin >> a >> b;
    p = pow(2, b);
    p %= pi;
    sum = 1;
    FOR(i, 0, b)
    {
        sum = ((sum % pi) * a) % pi;
    }

    cout << sum << endl;







    /*x = a * (a - 1);
    y = pow(2, b);
    //x /= 2;
    //y -= 2;
    x %= pi;
    y %= pi;

    if(a>b)
    {
        z=fact(b+1);
    }
    cout <<  (((x * y) % pi * (y)) % pi )  % pi << endl;*/


    //***************************************************************************
}

int main()
{
    RUN_FAST
    //PULOK SAHA
    //BMO
    ll sum = 1;
    FOR(i, 1, 1000000)
    {
        sum *= i;
        sum %= pi;
        F[i] = sum;
    }
    F[0] = 1;

    ll t = 1; //test case

    cin >> t;
    //ll j=1;
    while (t--)
    {
        //cout << "Case " << j << ": ";
        //j++;
        solve();
    }

    return 0;
}






//PULOK SAHA
