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.*;
  import java.math.*;
  import java.util.*;
  
  
  // @author : Dinosparton 
  
  public class test {
  	 
  	   static class Pair{ 
  		   long x;
  		   long y;
  		   
  		   Pair(long x,long y){ 
  			   this.x = x;
  			   this.y = y;
  			   
  		   }
  	   }
  	  
  	   static class Sort implements Comparator<Pair>
  	   {
  
  	       @Override
  	       public int compare(Pair a, Pair b)
  	       {
  	           if(a.x!=b.x)
  	           {
  	               return (int)(a.x - b.x);
  	           }
  	           else
  	           {
  	               return (int)(a.y-b.y);
  	           }
  	       }
  	   }
  	   
  	   static class Compare { 
  		   
  		     void compare(Pair arr[], int n) 
  		    { 
  		        // Comparator to sort the pair according to second element 
  		        Arrays.sort(arr, new Comparator<Pair>() { 
  		            @Override public int compare(Pair p1, Pair p2) 
  		            { 
  		            	if(p1.x!=p2.x) {
  		                return (int)(p1.x - p2.x); 
  		            	}
  		            	else { 
  		            		return (int)(p1.y - p2.y);
  		            	}
  		            } 
  		        }); 
  		  
  //		        for (int i = 0; i < n; i++) { 
  //		            System.out.print(arr[i].x + " " + arr[i].y + " "); 
  //		        } 
  //		        System.out.println(); 
  		    } 
  		} 
  	 
  	   static class Scanner {
  	        BufferedReader br;
  	        StringTokenizer st;
  	 
  	        public Scanner()
  	        {
  	            br = new BufferedReader(
  	                new InputStreamReader(System.in));
  	        }
  	 
  	        String next()
  	        {
  	            while (st == null || !st.hasMoreElements()) {
  	                try {
  	                    st = new StringTokenizer(br.readLine());
  	                }
  	                catch (IOException e) {
  	                    e.printStackTrace();
  	                }
  	            }
  	            return st.nextToken();
  	        }
  	 
  	        int nextInt() { return Integer.parseInt(next()); }
  	 
  	        long nextLong() { return Long.parseLong(next()); }
  	 
  	        double nextDouble()
  	        {
  	            return Double.parseDouble(next());
  	        }
  	 
  	        String nextLine()
  	        {
  	            String str = "";
  	            try {
  	                str = br.readLine();
  	            }
  	            catch (IOException e) {
  	                e.printStackTrace();
  	            }
  	            return str;
  	        }
  	    }
  	 
  	   static void printNcR(int n, int r)
  	    {
  	 
  	        // p holds the value of n*(n-1)*(n-2)...,
  	        // k holds the value of r*(r-1)...
  	        long p = 1, k = 1;
  	 
  	        // C(n, r) == C(n, n-r),
  	        // choosing the smaller value
  	        if (n - r < r) {
  	            r = n - r;
  	        }
  	 
  	        if (r != 0) {
  	            while (r > 0) {
  	                p *= n;
  	                k *= r;
  	 
  	                // gcd of p, k
  	                long m = __gcd(p, k);
  	 
  	                // dividing by gcd, to simplify
  	                // product division by their gcd
  	                // saves from the overflow
  	                p /= m;
  	                k /= m;
  	 
  	                n--;
  	                r--;
  	            }
  	 
  	            // k should be simplified to 1
  	            // as C(n, r) is a natural number
  	            // (denominator should be 1 ) .
  	        }
  	        else {
  	            p = 1;
  	        }
  	 
  	        // if our approach is correct p = ans and k =1
  	        System.out.println(p);
  	    }
  	 
  	    static long __gcd(long n1, long n2)
  	    {
  	        long gcd = 1;
  	 
  	        for (int i = 1; i <= n1 && i <= n2; ++i) {
  	            // Checks if i is factor of both integers
  	            if (n1 % i == 0 && n2 % i == 0) {
  	                gcd = i;
  	            }
  	        }
  	        return gcd;
  	    }
  	    
  	    static long mod = 1000000007;
  	    
  	    static long powerof2[] = new long[200005];
  	   public static void main(String args[]) throws Exception { 
  		
  		   
  		   Scanner sc = new Scanner();
  		   StringBuilder res = new StringBuilder();
  		 
  		   int tc = sc.nextInt();
  		   
  		   powerof2[0]=1;
  			for(int i=1;i<=2e5;i++){
  				powerof2[i]=powerof2[i-1]*2%mod;
  			}
  			
  		   while(tc-->0) { 
  			
  			  int n = sc.nextInt();
  			  int k = sc.nextInt();
  			 
  			  if(k==0){
  					System.out.println(1);
  					continue;
  				}
  				if(n%2==1){
  					int m=n;
  					long [] sum = new long[(k+1)];
  					long [] sum1 = new long[(k+1)];
  					sum[0]=1;
  					for(int i=1;i<=k;i++){
  						sum[i]=sum[i-1]*(powerof2[m-1]+1)%mod;
  					}
  					System.out.println(sum[k]);
  				}else{
  					int m=n;
  					long [] sum = new long[(k+1)];
  					long [] sum1 = new long[(k+1)];
  					sum[0]=1;
  					for(int i=1;i<=k;i++){
  						sum[i]=sum[i-1]*(powerof2[m-1]-1)%mod;
  					}
  					sum1[0]=1;
  					for(int i=1;i<=k;i++){
  						sum1[i]=sum1[i-1]*(powerof2[m])%mod;
  					}
  					long ans=sum[k];
  					
  					for(int i=1;i<=k;i++){
  						ans=(ans+(sum[i-1]*sum1[k-i]%mod))%mod;
  					}
  					System.out.println(ans);
  				}
  		   }
  			System.out.println(res);
  		   
  	   }
  }  
  
  
  
  
  