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.lang.reflect.Array;
  import java.util.*;
  
  public class tank {
  
      static final FastScanner fs = new FastScanner();
  
      //static PrintWriter out = new PrintWriter(System.out);
  
      public static void main(String[] args) {
          int t = fs.nextInt();
          while(t-- > 0) {
              run_case();
          }
  
          //out.close();
      }
  
      static void test() {
          int cnt = 0;
  
          for (int i = 0; i < 4; i++) {
              for (int j = 0; j < 4; j++) {
                  for (int k = 0; k < 4; k++) {
                      if((i & j & k) >= (i ^ j ^ k)) cnt++;
                  }
              }
          }
  
          System.out.println(cnt);
      }
  
      static void run_case() {
          int n = fs.nextInt(), k = fs.nextInt();
  
          if(k == 0) {
              System.out.println(1);
              return;
          }
  
          long[][] dp = new long[k][2];
  
          long less = fastPow(2, n - 1), eq = less;
  
          if(n % 2 != 0) {
              less--;
              eq++;
          }
          else eq--;
  
          dp[0][0] = less;
          dp[0][1] = eq;
  
          long tpn = fastPow(2, n);
  
          for (int i = 1; i < k; i++) {
              dp[i][0] = (tpn * dp[i - 1][0]) % mod;
              dp[i][0] = (dp[i][0] + (less * dp[i - 1][1]) % mod) % mod;
              dp[i][1] = (dp[i - 1][1] * eq) % mod;
          }
  
          System.out.println((fastPow((int) fastPow(2, n), k) - dp[k-1][0] + mod) % mod);
      }
  
      static final long mod = 1000_000_007;
  
      static long fastPow(int b, int p) {
          if(p == 0) return 1;
          else if(p == 1) return b;
          else {
              long r = fastPow(b, p/2);
              if(p % 2 == 0) return (r * r) % mod;
              else return (((r * r) % mod) * b) % mod;
          }
      }
  
      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();
          }
  
          String nextLine(){
              try {
                  return br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
              return "";
          }
  
          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());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
      }
  }