#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

#define F first
#define S second

ll mod = 1e9+7;

int power (ll a , ll b) {
	ll res = 1;
	while (b--) {
		res = (res * a) % mod;
	}
	return res;
}

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll t; cin >> t;
	while (t--) {
		ll n, k; cin >> n >> k;
		ll res = power (n , k);
		cout << res % mod << '\n';
	}
}

