8)

#include <bits/stdc++.h>
 
using namespace std;
 
void solve(){
    int n, k;
    cin>>n>>k;
    ll ans = 1;
    for(int i = 0; i < k; i++){
        ans = ans * n % mod;
    }
    
    cout<<ans;
}
 
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
 
    return 0;
}