#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> dictii;
typedef map<string, int> dictsi;
typedef map<string, string> dictss;
typedef pair<string, string> pss;
typedef set<int> si;
typedef set<string> ss;
typedef set<char> sc;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(a,b,c) for(int a=b;a<c;a++)
#define sut(a,b) (b*(b+1)/2 - a*(a+1)/2)
#define len(a) a.size()
#define FORD(a) for(const auto &[key, value] : a)
#define reverse(a) reverse(a.begin(), a.end())
#define nodup(v) v.erase(unique(v.begin(), v.end()), v.end())
#define string(d) to_string(d)
#define MAX_SIZE 1000005
 
 
 
const int mod = 1000000007;
const int max_n = 200005;
//Notes:
// 

void solve() {
int n,k;
cin >> n >> k;
long long ans=1;
		for(int i=0;i<k;i++)ans=ans*n%mod;
cout << ans << endl;
}
using namespace std;
int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int t;
cin >> t;
while(t--)
{
	solve();
}

   return 0;
}