#include<stdio.h>
//using namespace std;
int main()
{
    int n,k,i,T;
    long long ans=1LL;
    long long mod=(1E9)+7;
    scanf("%d",&T);
    while(T--)
    {
        ans=1LL;
    scanf("%d%d",&n,&k);
    for(i=0;i<k;i++)
    {
        ans=(ans*n)%mod;
    }
    printf("%lld\n",ans);
     }
}

#include<stdio.h>
int main(){
 int t;
 scanf("%d",&t);
 while(t--){
  int n,k;
  int max=1e9+7;
  scanf("%d%d",&n,&k);
  long long int ans=1;
  for(int i=0;i<k;i++){
   ans=(ans*n)%max;
  }
  printf("%lld\n",ans);
 }
 return 0;
}

#include <stdio.h>

int main()
{
 unsigned int t,k;
 unsigned long long int n,i;
 scanf("%u",&t);
 while(t--)
 {
     scanf("%llu%u",&n,&k);
     i=1;
     while(k--)
     {
         i=i*n%1000000007;
     }
printf("%llu",i);
printf("\n");
 }

    return 0;
}

#include <stdio.h>

enum{ MAX = 1000000007 };

int main()
{
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; ++i) {
        int n, k;
        scanf("%d%d", &n, &k);
        unsigned long long res = 1;
        for(int j = 0; j < k; ++j) {
            res *= n;
            res %= MAX;
        }
        printf("%llu\n", res);
    }
}

#include<stdio.h>
int main(){
  int t;
  scanf("%d",&t);
  while(t--){
    int n,k;
    scanf("%d %d",&n,&k);
    long long int ans = 1;
    for(int i=1; i<=k; i++){
      ans=ans*n;
      ans=ans%1000000007;
    }
    printf("%lld\n",ans);
  }
  return 0;
}

#include<stdio.h>
int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        long long int n, k, c=1;
        scanf("%lld %lld", &n, &k);
        while(k--)
            c=c*n%1000000007;
        printf("%lld\n", c);
    }
}

#include<stdio.h>
int main() {
	int t; scanf("%d", &t);
	int mod = 1e9 + 7;
	while (t--) {
		int n, k; scanf("%d%d", &n, &k);
		long long ans = 1;
		for (int i = 0; i < k; i++) {
			ans *= n;
			ans %= mod;
		}
		printf("%lld\n", ans);
	}
}

#include<stdio.h>
#include<string.h>
const int N=1000000007;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		long long a,b;
		scanf("%lld%lld",&a,&b);
		long long t=1;
		while(b--){
			t=t*a;
			t=t%N;
		}
		printf("%lld\n",t);
	}
	return 0;
}

#include <stdio.h>

#define M 1000000007

int min(int a, int b) { return a < b ? a : b; }

int main()
{
     int x,y,z,i,j,k,a,b,c,n,m,t;
     long long res;

     scanf("%d",&t);
     while(t--)
     {
           res = 1;
           scanf("%d %d",&n,&k);
           //k = min(n, k);
           for(x = 0; x < k; x++)
               res = (res * n) % M;

           printf("%lld\n",res);
     }
     return 0;
}

#include<stdio.h>

int main()
{
    long long int sum=1,n,k;
    long long int t;
    scanf("%lld",&t);
    for(long long int i=0;i<t;i++)
    {
        sum=1;
        scanf("%lld%lld",&n,&k);
        for(long long int j=0;j<k;j++)
            sum=(sum*n)%1000000007;
        printf("%lld\n",sum);
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>

void solve(){
    int n, k;
    scanf("%d %d", &n, &k);
    int mod = 1e9 + 7;
    long long ans = 1;
    for(int i = 0; i < k; i++){
        ans *= n;
        ans %= mod;
    }
    printf("%d\n", ans);
    return;
}

int main(){
    int t;
    scanf("%d", &t);
    for(int tt = 0; tt < t; tt++){
        solve();
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int t,n,k,max_sum;
    long long ans;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&k);
        ans=1;
        for(int i=0;i<k;i++)
        {
            ans*=n;
            ans%=1000000007;
        }
        printf("%d\n",ans);

    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

const unsigned long long int mod=1000000007;

void solve() {

int n,k;
scanf("%d %d",&n,&k);

unsigned long long int r=1;

for(int i=0; i<k; i++) {
    r=(r*n)%mod;
}
printf("%lld\n",r);

}

int main()
{
    int t;
    scanf("%d",&t);

    for(int i=0; i<t; i++) {
        solve();
    }
    return 0;
}

/**
 * @Author: Yang Li
 * @Date:   2022-03-15 22:45:18
 * @Last Modified by:   Yang Li
 * @Last Modified time: 2022-03-15 22:57:48
 */
/*
n^k % 1000000007
*/
# include <stdio.h>

int main () {
    int t;
    scanf("%d", &t);
    while (t--) {
        long long n;
        int k;
        scanf("%lld %d", &n, &k);
        long long cnt = 1;
        for (int i = 0; i < k; i++) {
            cnt *= n;
            cnt %= 1000000007;
        }
        printf("%lld\n", cnt);
    }
    return 0;
}

#include <stdio.h>

const long long MOD = 1e9 + 7;

int main() {
  long long t, n, k, ans;
  scanf("%I64d", &t);
  while (t--) {
    scanf("%I64d%I64d", &n, &k);
    ans = 1; while (k--) ans = ans * n % MOD;
    printf("%I64d\n", ans);
  }
  return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double lld;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
void swap(int *a, int *b) {
    int t = *a;
    *a = *b;
    *b = t;
}
typedef struct array {
    int first, second, third;
} point;
ll  min(ll  a, ll b) {
    return a < b ? a : b;
}
ll max(ll a, ll b) {
    return a > b ? a : b;
}
int cmpfunc (const void * a, const void * b) {
    return ( * (int*)a - * (int*)b );
}
int cmc(const void *a, const void *b) {
    return *(char *)b - *(char *)a;
}
int comp(const void* a, const void* b) {
    long long i = *(long long*)a;
    long long j = *(long long*)b;
    return (int)((i > j) - (i < j));
}
#define pr printf
#define sc scanf
#define re(i,a,b) for(int i=a;i<b;i++)
#define I 1e18
#define in32(x) scanf("%d", &x)
#define out32(x) printf("%d\n", x)
//qsort(a, n, sizeof(int), cmpfunc);
void test();
int main()
{
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    int t;
    scanf("%d", &t);
    while (t--)
    {
        test();
    }
}
void test()
{

    ll n, k;
    sc("%lld %lld", &n, &k);
    ll res = 1, m = 1e9 + 7;
    while (k > 0)
    {
        if (k & 1)
        {
            res = (res * n % m) % m;
        }
        n = n % m * n % m;
        k = k >> 1;
    }
    printf("%lld\n", res);

}

#include<stdio.h>
#define ll long long
#define MOD 1000000007
int main(){
    int t;
    scanf("%d",&t);

    while(t--){

        int n,k;
        scanf("%d%d",&n,&k);

        ll ans = 1;
        for(int i = 0 ; i < k; i++){
            ans *= n;
            if(ans >= MOD){
                ans %= MOD;
            }
        }
        printf("%lld\n",ans);

    }

    return 0;
}

#include <stdio.h>
const int N=1e+9+7;

int main()
{
	long long int a,b,c,d;
	scanf("%lld",&a);
	while(a--) {
		d=1;
		scanf("%lld%lld",&b,&c);
		while(c--) d=(d*b)%N;
		printf("%lld\n",d);
	}
}

#include <stdio.h>
#define div 1000000007
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        long long n,k,ans=1;
        scanf("%lld %lld",&n,&k);
        for(int i=0;i<k;i++){
            ans=ans*n%div;
        }
        printf("%lld\n",ans);
    }

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef long long int ll;
ll p=1000000000+7;
int main()
{
    int t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        ll n,k,ans=1,j;
        scanf("%lld%lld",&n,&k);
       for(j=1;j<=k;j++)
       {
           ans=(ans*n)%p;
       }
       printf("%lld\n",ans);
    }
    return 0;
}

#include <stdio.h>
void main(){
	long long  mod = 1000000007;
	int t;
	scanf("%d",&t);
	while (t--){
		long long  n,k;
		scanf("%lld %lld",&n,&k);
		long long ans = 1;
		for (int i=0;i<k;i++){
			ans = (ans*n)%mod;
		}
		printf("%lld\n",ans );

	}

}

#include<stdio.h>
#define f 1000000007
int main()
{
	int n;
	long long sum;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a,b;
		sum=1;
		scanf("%d %d",&a,&b);
		for(int j=1;j<=b;j++){
			sum*=a;
			sum%=f;
		}
		printf("%d\n",sum);
	}
	return 0;
}

#include <stdio.h>
int main()
{
        int no_of_test_cases;
        scanf("%d",&no_of_test_cases);
        long long int no_of_bits,k;
        int no_of_numbers;
        for(int i=0;i<no_of_test_cases;i++)
        {
          scanf("%lld",&no_of_bits);
          scanf("%d",&no_of_numbers);
          //printf("%lld %d\n",no_of_bits,no_of_numbers);
          k = no_of_bits;
          for(int j=0;j<no_of_numbers-1;j++)
          {
              no_of_bits *= k;
              //printf("%ld\n",no_of_bits);
              if(no_of_bits > 1000000007)
              {
                  no_of_bits = (no_of_bits%1000000007);
              }
          }
          printf("%lld\n",no_of_bits);
        }
}

#include <stdio.h>

int main()
{
    int n,k,i,j,test;
    long long int c;
    scanf("%d",&test);
    for(i=1;i<=test;i++)
    {
        c=1;
        scanf("%d",&n);
        scanf("%d",&k);
        for(j=1;j<=k;j++)
        {
            c=(c*n)%(1000000000+7);
        }
        printf("%lld\n",c);
    }
    return 0;
}

#include<stdio.h>
const long long int max=1e9+7;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long int n,k;
        scanf("%lld%lld",&n,&k);
        long long int sum=1;
        for(int i=0; i<k; i++)
        {
            sum=(sum*n)%max;
        }
        printf("%lld\n",sum);
    }
}

#include <stdio.h>
#define forin(i, n) for (i = 0; i < n; i++)
#define lli long long int
#define printSp(i, a, n) forin(i, n) printf('%d ', a[i]);
#define printLn(i, a, n) forin(i, n) printf('%d\n', a[i]);
#define fis(n) fast_int_scan(n)
#define fls(n) fast_long_scan(n)
#define flli(n) fast_lli_scan(n)
#define scanIA(i, a, n) forin(i, n) fis(a + i);
#define scanLA(i, a, n) forin(i, n) fls(a + i);
#define scanLLIA(i, a, n) forin(i, n) flli(a + i);

void fast_int_scan(int *number)
{
    //variable to indicate sign of input number
    int negative = 0;
    register int c;

    *number = 0;

    // extract current character from buffer
    c = getchar();
    if (c == '-')
    {
        // number is negative
        negative = 1;

        // extract the next character from the buffer
        c = getchar();
    }

    // Keep on extracting characters if they are integers
    // i.e ASCII Value lies from '0'(48) to '9' (57)
    for (; (c > 47 && c < 58); c = getchar())
        (*number) = (*number) * 10 + c - 48;

    // if scanned input has a negative sign, negate the value
    if (negative)
        (*number) *= -1;
}

void fast_lli_scan(lli *number)
{
    //variable to indicate sign of input number
    int negative = 0;
    register int c;

    *number = 0;

    // extract current character from buffer
    c = getchar();
    if (c == '-')
    {
        // number is negative
        negative = 1;

        // extract the next character from the buffer
        c = getchar();
    }

    // Keep on extracting characters if they are integers
    // i.e ASCII Value lies from '0'(48) to '9' (57)
    for (; (c > 47 && c < 58); c = getchar())
        (*number) = (*number) * 10 + c - 48;

    // if scanned input has a negative sign, negate the value
    if (negative)
        (*number) *= -1;
}

int main(void)
{
	int T;
	fast_int_scan(&T);
	while (T--)
	{
		lli n, k, i, sum = 1;
		fast_lli_scan(&n);
        fast_lli_scan(&k);
		for(i=1; i<=k; i++)
		{
			sum *= n;
			sum %= 1000000007;
		}

		printf("%lld\n", sum);
	}
	return 0;
}

#include <stdio.h>

int main(void) {
	unsigned t, k;
	unsigned long long n, i;

	scanf("%u", &t);

	while (t--) {
		scanf("%llu %u", &n, &k);

		i = 1;

		while (k--) {
			i *= n;
			i %= 1000000007;
		}

		printf("%llu\n", i);
	}
}

//每一个元素最多有k位 高于k位不考虑
//要使数组元素尽可能大且所有元素按位与为0
//即所有元素的2进制每一位都有且仅有一个为0
//每一位有n种可能，结果为n^k
#include<stdio.h>
const int mod=1e9+7;
int duqi(int n,int k){
	long long p=n,sum=1;
	while(k!=0){
	p=p%mod;
	if(k%2==0){
		k/=2;p*=p;
	}
	else{
		k/=2;sum=sum*p%mod;p*=p;
	}
	}
	return sum;
}
int main()
{
	int k,n,t;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&n,&k);
		printf("%d\n",duqi(n,k));
	}
}

#include <stdio.h>
#include<math.h>

int n,k;
const int MOD=1e9+7;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&n,&k);
        long long ans=1;
        for(int i=0;i<k;i++) ans=(ans*n)%MOD;
        printf("%lld\n",ans);
    }
}

#include<stdio.h>
const long long mod=1e9+7;
long long f(long long n,long long k){
	long long sum=1,i;
	for(i=1;i<=k;i++){
		sum=sum%mod*n%mod;
	}
	return sum;
}
int main(void){
	long long t;
	long long n,k;
	long long ans;
	scanf("%lld",&t);
	while(t--){
		scanf("%lld%lld",&n,&k);
		ans=f(n,k)%mod;
		printf("%lld\n",ans);
	}
	return 0;
}

#include<stdio.h>
#define ll long long
#define rep(a,b) for(ll i=a;i<b;i++)
#define N 1000000007
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		ll a,b;
		scanf("%lld %lld",&a,&b);
		ll ta=a;
		rep(1,b)
		{
			a*=ta;
			a%=N;
		}
		printf("%lld\n",a);

	}
}

#include <stdio.h>
#define MOD 1000000007
#define ll long long

int main(void)
{
    int t;
    scanf("%d", &t);

    while (t--) {

        int n, k;
        scanf("%d%d", &n, &k);

        ll result = n;
        for (int i = 1; i < k; i++) {
            result = result * n % MOD;
        }
        printf("%lld\n", result);
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		long long int n,k,i,sum=1;
		scanf("%lld %lld",&n,&k);
		for(i=1;i<=k;i++)
		{
			sum*=n;
			sum=sum%(1000000000+7);
		}
		printf("%lld\n",sum);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int t,n,k,i,j;long long s;
    scanf ("%d",&t);
    for (i=0;i<t;i++)
    {
        s=1;
        scanf ("%d %d",&n,&k);
        for (j=0;j<k;j++)
        {
            s=(s*n)%1000000007;
        }
        printf ("%lld\n",s);
    }
return 0;
}

#include<stdio.h>
#define ll long long
const int mod=1e9+7;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,k;
		scanf("%d%d",&n,&k);
		ll ans=1;
		for(int i=1;i<=k;i++)
		{
			ans=(ans*n)%mod;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD (1000000007)

int main(void)
{
	int TC, tcase, n, k;
	scanf("%d", &TC);
	for (tcase = 0; tcase < TC; tcase++)
	{
		scanf("%d %d", &n, &k);
		long long p = 1;
		for (int i = 0; i < k; ++i)
		{
			p = (p * n) % MOD;
		}
		printf("%lld\n", p);
	}
	return 0;
}

#include <stdio.h>

long long K = 1000000000+7;

int main() {
    long long t, n, k, i, sol, j;
    scanf("%lld", &t);

    for( i = 0; i < t; i++ ){
        scanf("%lld", &n);
        scanf("%lld", &k);
        sol = 1;
        for( j = 0; j < k; j++ )
            sol = (sol*n)%K;
        printf("%lld\n", sol);
    }
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long long (ll);
#define A 10005
#define M 1000000007
ll z[A],p[A],q[A],r[A];
char s[A];

void merge(ll arr[],ll l,ll m,ll r)
{
    ll i,j,k,n1,n2;
    n1=m-l+1;
    n2=r-m;
    ll L[n1],R[n2];
    for(i=0;i<n1;i++)
		L[i]=arr[l+i];
    for(j=0;j<n2;j++)
		R[j]=arr[m+1+j];
    i=j=0;
	k=l;
    while(i<n1&&j<n2)
    {
        if(L[i]<R[j])
            arr[k++]=L[i++];
        else
            arr[k++]=R[j++];
    }
    while(i<n1)
        arr[k++]=L[i++];
    while(j<n2)
        arr[k++]=R[j++];
}
void sort(ll arr[],ll l,ll r)
{
    if(l<r)
    {
        ll m=l+(r-l)/2;
        sort(arr,l,m);
		sort(arr,m+1,r);
		merge(arr,l,m,r);
    }
}
int main()
{
	ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o;m=M;
	scanf("%lli",&a);
	for(b=1;b<=a;b++)
	{
		scanf("%lli%lli",&c,&d);
		for(e=1;d;d--)
		{
			e*=c;
			e%=m;
		}
		printf("%lli\n",e);
	}
	return 0;
}

#include <stdio.h>
long long BP(long long a, long long b, long long p)
{
	long long r = 1;
	while (b)
	{
		if (b & 1)
		{
			r *= a;
			r %= p;
		}
		a *= a;
		a %= p;
		b >>= 1;
	}
	return r;
}
int main()
{
	int T;
	long long n, k;
	long long R;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%I64d %I64d", &n, &k);
		R = BP(n, k, 1000000007);
		printf("%I64d\n", R);
	}
	return 0;
}

#include<stdio.h>

int t;
int n,k;
long long mod;

long long p(int nn,int kk)
{
	long long mm,tt;
	mm=1;
	tt=nn;
	while(kk){
		if(kk%2){
			mm=mm*tt%mod;
		}
		tt=tt*tt%mod;
		kk/=2;
	}
	return mm;
}

int main()
{
	mod=1000000007;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&n,&k);
		printf("%lld\n",p(n,k));
	}
	return 0;
}

#include<stdio.h>
int main(){
 int t;
 scanf("%d",&t);

 while(t--){
  int n,k;
  int max=1e9+7;
  scanf("%d%d",&n,&k);
  long long int ans=1;
  for(int i=1;i<=n;i++){
   ans=(ans*i)%max;
  }
  printf("%lld",ans);
 }
 return 0;
}

#include <stdio.h>
int a[100000];
int main()
{
 unsigned int t,n,k;
 scanf("%d",&t);
 while(t--)
 {
     scanf("%d%d",&n,&k);
     int d,l=0,new=0,kk=0;
    while(k--){
         l=0,new=0;
     while(n)
     {
        d=n%10;
        a[l]=d+1;
        l++;
        n/=10;
     }
     kk=0;
    while(l--)
    {
       if(a[l]==10)
       {  new=new*10+1;
          new=new*10+0;kk=kk+2;
          continue; }
        new=new*10+a[l]; kk++;   }
    n=new;
    }

    printf("\n%d",kk);
 }

    return 0;
}

#include <stdio.h>

int main()
{
 unsigned int t,k;
 unsigned long long int n,i;
 scanf("%u",&t);
 while(t--)
 {
     scanf("%llu%u",&n,&k);
     i=1;
     while(k--)
     {
         i=i*n%1000000007;
     }
printf("%\nllu",i);
 }

    return 0;
}

#include <stdio.h>

int main()
{
 unsigned int t,k;
 unsigned long long int n,i;
 scanf("%u",&t);
 while(t--)
 {
     scanf("%llu%u",&n,&k);
     i=1;
     while(k--)
     {
         i=i*n%1000000007;
     }
printf("%llu",i);
 }

    return 0;
}

#include <stdio.h>

enum{ MAX = 1000000007 };

int main()
{
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; ++i) {
        int n, k;
        scanf("%d%d", &n, &k);
        unsigned long res = 1;
        for(int j = 0; j < k; ++j) {
            res *= n;
            res %= MAX;
        }
        printf("%lu\n", res);
    }
}

#include <stdio.h>

enum{ MAX = 1000000007 };

int main()
{
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; ++i) {
        int n, k;
        scanf("%d%d", &n, &k);
        long res = 1;
        for(int j = 0; j < k; ++j) {
            res *= n;
            res %= MAX;
        }
        printf("%ld\n", res);
    }
}

#include<stdio.h>
int main(){
  int t;
  scanf("%d",&t);
  while(t--){
    int n,k;
    scanf("%d %d",&n,&k);
    long long int ans = 0;
    for(int i=1; i<=k; i++){
      ans=ans*n;
      ans=ans%1000000007;
    }
    printf("%lld\n",ans);
  }
  return 0;
}

#include<stdio.h>
int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int n, k, c=1;
        scanf("%d %d", &n, &k);
        while(k--)
            c=c*n;
        printf("%d", c%1000000007);
    }
}

#include<stdio.h>
int main() {
	int t; scanf("%d", &t);
	int mod = 1e9 + 7;
	while (t--) {
		int n, k; scanf("%d%d", &n, &k);
		int ans = 1;
		for (int i = 0; i < k; i++) {
			ans *= n;
			ans %= mod;
		}
		printf("%d\n", ans);
	}
}

#include<stdio.h>
int a=1e9+7;
int main(){
	int t;
	long long int ans,n,k;
	scanf("%d",&t);
	while(t--){
		ans=1;
		scanf("%d %d",&n,&k);
		n=n%a;
		while(k>0){
			if(k%2==1){
				ans=(ans*n)%a;
			}
			k=k/2;
			n=(n*n)%a;

		}
		printf("%d\n",ans);
	}
	return 0;
}

#include <stdio.h>

#define M 1000000007

int min(int a, int b) { return a < b ? a : b; }

int main()
{
     int x,y,z,i,j,k,a,b,c,n,m,t;
     long long res;

     scanf("%d",&t);
     while(t--)
     {
           res = 1;
           scanf("%d %d",&n,&k);
           k = min(n, k);
           for(x = 0; x < k; x++)
               res = (res * n) % M;

           printf("%lld\n",res);
     }
     return 0;
}

#include<stdio.h>

int main()
{
    long long int sum=1,n,k;
    int t;
    scanf("%d",&t);
    for(int i=0;i<t;i++)
    {
        sum=1;
        scanf("%d %d",&n,&k);
        for(int j=0;j<k;j++)
            sum=(sum*n)%1000000007;
        printf("%lld\n",sum);
    }
    return 0;
}