#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        int n,k; cin>>n>>k;long long int res=1;
        while(k--){
            res=(res*n)%M;
        }
        cout<<res<<endl;
    }
    return 0;
}
