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.util.Scanner; 
  import java.util.StringTokenizer;
  import java.util.*;
  public class codeforcesA{
     static class FastReader 
      { 
          BufferedReader br; 
          StringTokenizer st; 
   
          public FastReader() 
          { 
              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 long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
     static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
     static long ModInv(long a,long m){return Modpow(a,m-2,m);}
     static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
     static long[] f;
     public static void main(String args[]){
       FastReader sc=new FastReader();
       int t=sc.nextInt();
       while(t-->0){
          long mod=1000000007;
          int n=sc.nextInt();
          int k=sc.nextInt();
          long ans=1,x=0;
          
          f=new long[n+1];f[0]=1l;
          for(int i=1;i<=n;i++){
            f[i]=Modmul(f[i-1],(long)i,mod);
          }
          for(int i=0;i<n;i+=2){
           x=(x+nck(n,i,mod))%mod;
          }
          
          if(n%2==1){x=(x+1)%mod;}
          for(int i=0;i<k;i++){ans=Modmul(x,ans,mod);}
          if(k!=0 && n%2==0){
            long pow_2=1;
            for(int i=0;i<n;i++){pow_2=Modmul(pow_2,(long)2,mod);}
            long ar[]=new long[k];
            ar[0]=1;
            for(int i=1;i<k;i++){ar[i]=Modmul(ar[i-1],pow_2,mod);}
            long prev=1;
            for(int i=k-1;i>=0;i--){
              ans=(ans+Modmul(prev,ar[i],mod))%mod;
                prev=Modmul(prev,x,mod);
              }
          }
          System.out.println(ans%mod);
       }
      }
  }