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.util.*;
  //200000 200000
  //226490044
  public class CodeForces{
      /*****************************************WRITING CODE STARTS HERE******************************************/
      public static void solve(int tCase)throws IOException {
         int n = sc.nextInt();
         int k = sc.nextInt();
         dp = new long[k][2];
         for(int i=0;i<k;i++)Arrays.fill(dp[i],-1);
         out.println(memo(0,k,n,1));
      }
      static long[][] dp;
      private static long memo(int bit,int k,int n,int tight){
          if(bit == k)return 1;
          if(dp[bit][tight]!=-1)return dp[bit][tight];
          long rightSet = n%2==1?1:0;
          long rightNotSet = _power(2,n-1) -(n%2==0?1:0);
          if(tight == 1){
              long ans = 0;
              if(rightSet == 0)ans += memo(bit+1,k,n,0);
              else ans += memo(bit+1,k,n,1);
              ans += ((rightNotSet*memo(bit+1,k,n,1)) % mod);
              return dp[bit][tight] = ans%mod;
          }else {
              return dp[bit][tight] = (_power(2,n) * memo(bit+1,k,n,0)) % mod;
          }
      }
      /*****************************************WRITING CODE ENDS HERE******************************************/
  
      public static void main(String[] args) throws IOException{
          openIO();
          int testCase = 1;
          testCase = sc.nextInt();
          for (int i = 1; i <= testCase; i++) solve(i);
          closeIO();
      }
      static FastestReader sc;
      static PrintWriter out;
      private static void openIO() throws IOException{
           sc = new FastestReader();
           out = new PrintWriter(System.out);
      }
  
      /**************************************HELPER FUNCTION STARTS HERE ************************************/
  
      public static int mod = (int) 1e9 +7;
      public static  int inf_int = (int) 1e9;
      public static  long inf_long = (long) 1e15;
  
      public static final String YES = "YES";
      public static final String NO = "NO";
  
      // euclidean algorithm time O(max (loga ,logb))
      public static long _gcd(long a, long b) {
          long x = Math.min(a, b);
          long y = Math.max(a, b);
          if (y % x == 0) return x;
          return _gcd(y % x, x);
      }
  
      public static long _lcm(long a, long b) {
          // lcm(a,b) * gcd(a,b) = a * b
          return (a / _gcd(a, b)) * b;
      }
      // binary exponentiation time O(logn)
      public static long _power(long x, long n) {
          long ans = 1;
          while (n > 0) {
              if ((n & 1) == 1) {
                  ans *= x;
                  ans %= mod;
                  n--;
              } else {
                  x *= x;
                  x %= mod;
                  n >>= 1;
              }
          }
          return ans;
      }
  
      public static long _firstDivisor(long n) {
          if (n == 1 || n == 0) return n;
          for (long i = 2; i * i <= n; i++)
              if (n % i == 0) return i;
          return -1;
      }
  
  
      /**************************************HELPER FUNCTION ENDS HERE ************************************/
  
      /*****************************************FAST INPUT STARTS HERE *************************************/
  
      public static void closeIO() throws IOException{
          out.flush();
          out.close();
          sc.close();
      }
      private static final class FastestReader {
          private static final int BUFFER_SIZE = 1 << 16;
          private final DataInputStream din;
          private final byte[] buffer;
          private int bufferPointer, bytesRead;
  
          public FastestReader() {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          public FastestReader(String file_name) throws IOException {
              din = new DataInputStream(new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
  
          private int skip() throws IOException {
              int b;
              //noinspection StatementWithEmptyBody
              while ((b = read()) != -1 && isSpaceChar(b)) {}
              return b;
          }
  
          public String next() throws IOException {
              int b = skip();
              final StringBuilder sb = new StringBuilder();
              while (!isSpaceChar(b)) { // when nextLine, (isSpaceChar(b) && b != ' ')
                  sb.appendCodePoint(b);
                  b = read();
              }
              return sb.toString();
          }
  
          public int nextInt() throws IOException {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              final boolean neg = c == '-';
              if (neg) { c = read(); }
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
  
              if (neg) { return -ret; }
              return ret;
          }
  
          public long nextLong() throws IOException {
              long ret = 0;
              byte c = read();
              while (c <= ' ') { c = read(); }
              final boolean neg = c == '-';
              if (neg) { c = read(); }
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg) { return -ret; }
              return ret;
          }
  
          public double nextDouble() throws IOException {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ') { c = read(); }
              final boolean neg = c == '-';
              if (neg) { c = read(); }
  
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
  
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
  
              if (neg) { return -ret; }
              return ret;
          }
  
          private void fillBuffer() throws IOException {
              bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
              if (bytesRead == -1) { buffer[0] = -1; }
          }
  
          private byte read() throws IOException {
              if (bufferPointer == bytesRead) { fillBuffer(); }
              return buffer[bufferPointer++];
          }
  
          public void close() throws IOException {
              din.close();
          }
  
      }
      /*****************************************FAST INPUT ENDS HERE *************************************/
  }