description: Moamen and Ezzat are playing a game. They create an array a of n non-negative integers where every element is less than 2^k.
  
  Moamen wins if a_1  \&  a_2  \&  a_3  \&  …  \&  a_n ≥ a_1 ⊕ a_2 ⊕ a_3 ⊕ … ⊕ a_n.
  
  Here \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND), and ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
  
  Please calculate the number of winning for Moamen arrays a.
  
  As the result may be very large, print the value modulo 1 000 000 007 (10^9 + 7).
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 5)— the number of test cases. 
  
  Each test case consists of one line containing two integers n and k (1 ≤ n≤ 2⋅ 10^5, 0 ≤ k ≤ 2⋅ 10^5).
  
  Output
  
  For each test case, print a single value — the number of different arrays that Moamen wins with.
  
  Print the result modulo 1 000 000 007 (10^9 + 7).
  
  Example
  
  Input
  
  
  3
  3 1
  2 1
  4 0
  
  
  Output
  
  
  5
  2
  1
  
  Note
  
  In the first example, n = 3, k = 1. As a result, all the possible arrays are [0,0,0], [0,0,1], [0,1,0], [1,0,0], [1,1,0], [0,1,1], [1,0,1], and [1,1,1].
  
  Moamen wins in only 5 of them: [0,0,0], [1,1,0], [0,1,1], [1,0,1], and [1,1,1].
solution: import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
   
   
   
   
  public class Codeforces {
  	
  	static int mod=1000000007;
  	
  	
  	public static void main(String[] args) throws Exception {
  		PrintWriter out=new PrintWriter(System.out);
  	    FastScanner fs=new FastScanner();
  	    int t=fs.nextInt();
  	    while(t-->0) {
  	    	int n=fs.nextInt();
  	    	int k=fs.nextInt();
  	    	if(n%2==0)
  	    	System.out.println(even(n,k));
  	    	else System.out.println(odd(n,k));
  	    }
      	out.close();
  	    
  	}
  	static long odd(int n,int k) {
  		long cur=pow(2,n-1)+1;
      	
  //    	long mul=pow(2,k-1);
      	long ans=1;
      	for(int i=0;i<k;i++) {
  //    		ans+=(cur*mul)%mod;
  //    		ans%=mod;
  //    		mul>>=1;
      		ans*=cur;
      		ans%=mod;
      	}
  //    	long res=0;
  //    	for(int j=k-1;j>=0;j--) {
  //    		res+= pow(2,n*j);
  //    		res%=mod;
  //    	}
      	return ans;
  	}
  	static long even(long n,long k) {
  		long cur=pow(2,n-1);
      	cur--;
      	long ans=0;
      	for(int i=0;i<=k;i++) {
  //    		ans+=(cur*mul)%mod;
  //    		ans%=mod;
  //    		mul>>=1;
      		long res=pow(cur,i);
      		if(i<k-1) {
      			res*=pow(2,n*(k-1-i));
      			res%=mod;
      		}
      		ans+=res;
      		ans%=mod;
      	}
      	return ans;
  //    	long res=0;
  //    	for(long j=k-1;j>=0;j--) {
  //    		res+= pow(2,n*j);
  //    		res%=mod;
  //    	}
  //    	return (res+ans)%mod;
  	}
  	static long pow(long a,long b) {
  		if(b<0) return 1;
  		long res=1;
  		while(b!=0) {
  			if((b&1)!=0) {
  				res*=a;
  				res%=mod;
  			}
  			a*=a;
  			a%=mod;
  			b=b>>1;
  		}
  		return res;
  	}
  	static long gcd(long  a,long  b) {
  		if(b==0) return a;
  		return gcd(b,a%b);
  	}
  	static long nck(int n,int k) {
  		if(k>n) return 0;
  		long res=1;
  		res*=fact(n);
  		res%=mod;
  		res*=modInv(fact(k));
  		res%=mod;
  		res*=modInv(fact(n-k)); 
  		res%=mod;
  		return res;
  	}
  	static long fact(long n) {
  		long res=1;
  		for(int i=2;i<=n;i++) {
  			res*=i;
  			res%=mod;
  		}
  		return res;
  	}
  	
  	static long modInv(long n) {
  		return pow(n,mod-2);
  	}
  	
  	static void sort(int[] a) {
  		//suffle
  		int n=a.length;
  		Random r=new Random();
  		for (int i=0; i<a.length; i++) {
  			int oi=r.nextInt(n);
  			int temp=a[i];
  			a[i]=a[oi];
  			a[oi]=temp;
  		}
  		
  		//then sort
  		Arrays.sort(a);
  	}
  	
  	// Use this to input code since it is faster than a Scanner
  	static class FastScanner {
  		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st=new StringTokenizer("");
  		String next() {
  			while (!st.hasMoreTokens())
  				try {
  					st=new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			return st.nextToken();
  		}
  		
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  		int[] readArray(int n) {
  			int[] a=new int[n];
  			for (int i=0; i<n; i++) a[i]=nextInt();
  			return a;
  		}
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  	}
   
  }