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: // Don't place your source in a package
  
  
  import javax.swing.*;
  import java.lang.reflect.Array;
  import java.text.DecimalFormat;
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  import java.math.*;
  import java.util.stream.Stream;
  
  
  
  // Please name your class Main
  public class Main {
      static FastScanner fs=new FastScanner();
      static class FastScanner {
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          StringTokenizer st=new StringTokenizer("");
          public String next() {
              while (!st.hasMoreElements())
                  try {
                      st=new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              return st.nextToken();
          }
          int Int() {
              return Integer.parseInt(next());
          }
  
          long Long() {
              return Long.parseLong(next());
          }
  
          String Str(){
              return next();
          }
      }
  
  
      public static void main (String[] args) throws java.lang.Exception {
          PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
          //reading /writing file
          //Scanner sc=new Scanner(new File("input.txt"));
          //PrintWriter pr=new PrintWriter("output.txt");
  
  
  
          int T=Int();
          for(int t=0;t<T;t++){
              int n=Int();
              int k=Int();
  
              Solution sol1=new Solution(out);
              sol1.solution(n,k);
          }
          out.close();
  
      }
  
  
      public static int[] Arr(int n){
          int A[]=new int[n];
          for(int i=0;i<n;i++)A[i]=Int();
          return A;
      }
      public static int Int(){
          return fs.Int();
      }
      public static long Long(){
          return fs.Long();
      }
      public static String Str(){
          return fs.Str();
      }
  
  }
  
  
  
  
  
  
  
  
  class Solution {
      PrintWriter out;
      int INF = Integer.MAX_VALUE;
      int MOD = 1000000007;
      long mod = 1000000007;
  
      public Solution(PrintWriter out) {
          this.out = out;
  
      }
  
  
      long dp[];
      int n;
      public void solution(int n,int k) {
          if(k==0){
              out.println(1);
              return;
          }
  
          long res=0;
          long p = pow(2,n-1);
          if(n%2==1){
              res=pow(pow(2,n-1)+1,k);
          }
          else{
              long cur = 1;
              for(int i=k-1;i>=0;i--){
                  //all 1
                  long a = pow(pow(2,n),i);
                  res += (a*cur);
                  res%=mod;
                  cur = cur * (p - 1);
                  cur%=mod;
              }
              res +=cur;
              res%=mod;
          }
          out.println(res);
      }
  
  
  
  
      public long pow(long a,long b){
          if(b<0)return 1;
          long res=1;
          long pow=a;
          for(int i=0;i<32;i++){
              if((b&(1l<<i))!=0){
                  res*=pow;
                  res%=mod;
              }
              pow*=pow;
              pow%=mod;
          }
          return res;
      }
  }
  
  
  
  
  