#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define f first
#define s second
#define md 1000000007

ll f(int x)
{
    int ans = 1;
    while (x)
    {
        ans = (ans * 1ll * x) % md;
        x--;
    }
    return ans;
}

void solve()
{
    int n, k;
    cin >> n >> k;

    int ans = 1;
    for (int i = 0; i < k; i++)
    {
        ans = (ans * 1ll * n) % md;
    }
    cout << ans << endl;
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();
}