#include<bits/stdc++.h>
using namespace std;
#define P 1000000007 
int power(int a , int n)
{
	int res = 1;
	while(n)
	{
		if(n%2)
		{
			res = (res*1LL*a)%P;
		}
		n/=2;
		a = (a*1LL*a)%P;
		
	}
	return res;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k,x=1;
        cin>>n>>k;
        n= power(n,k);
            cout<<n<<"\n";
        
    }
    return 0;
}