//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
////#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define ppb pop_back

const long long INF = 999999999999999999;
const int MAXN = 200005;
const int MOD = 1000000007;

long long tt, n, k, ans;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> tt;

    while(tt--){
        cin >> n >> k;
        ans = 1;
        for(long long i = 1; i <= k; ++i){
            ans *= n;
            ans %= MOD;
        }
        cout << ans << '\n';
    }

    return 0;
}

