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.FileInputStream;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.InputMismatchException;
  
  public class Solution {
  
      static class NCR {
          private final long[] fact;
          private final long[] inv;
          private final long[] invfact;
          private final int MOD = 1_000_000_007;
          private final int n;
  
          public NCR(int n) {
              this.n = n;
              fact = new long[n];
              inv = new long[n];
              invfact = new long[n];
              factInverse();
          }
  
          public int nCr(int n, int r) {
              if (r > n) {
                  return 0;
              }
              return (int) ((((fact[n] * invfact[r]) % MOD) * invfact[n - r]) % MOD);
          }
  
          private void factInverse() {
              fact[0] = inv[1] = fact[1] = invfact[0] = invfact[1] = 1;
              for (int i = 2; i < n; i++) {
                  fact[i] = (fact[i - 1] * i) % MOD;
                  inv[i] = MOD - (inv[MOD % i] * (MOD / i) % MOD);
                  invfact[i] = (inv[i] * invfact[i - 1]) % MOD;
              }
          }
      }
  
      static NCR ncr;
  
      public static void main(String[] args) throws Exception {
          ncr = new NCR(200001);
          int t = io.nextInt();
  //        int t = 1;
          for (int i = 0; i < t; i++) {
              solve();
          }
          io.close();
      }
  
      private static void solve() {
          int n = io.nextInt();
          int k = io.nextInt();
  //
  //        for (int i = 0; i < 5; i++) {
  //            for (int j = 0; j <= i; j++) {
  //                io.print(nCr(i, j) + " ");
  //            }
  //            io.println();
  //        }
          int MOD = 1_000_000_007;
  
          long numberOfWayToChooseEven = 0;
          for (int i = 0; i < n; i += 2) {
              numberOfWayToChooseEven += ncr.nCr(n, i);
              numberOfWayToChooseEven %= MOD;
          }
          long pow2n = pow(2, n);
  
          long[][] dp = new long[k + 1][2];
          dp[0][0] = 1;
          dp[0][1] = 1;
          for (int i = 1; i <= k; i++) {
              dp[i][0] = dp[i - 1][0] * pow2n;
              dp[i][0] %= MOD;
              if (n % 2 == 1) {
                  dp[i][1] = dp[i - 1][1] * (numberOfWayToChooseEven + 1);
                  dp[i][1] %= MOD;
              } else {
                  dp[i][1] = dp[i - 1][1] * numberOfWayToChooseEven;
                  dp[i][1] %= MOD;
                  dp[i][1] += dp[i - 1][0];
                  dp[i][1] %= MOD;
              }
          }
          io.println(dp[k][1]);
      }
  
      static long pow(long n, int p) {
          if (p == 0) {
              return 1;
          }
          long v = pow(n, p / 2);
          long res = 1;
          if (p % 2 == 1) {
              res = n;
          }
          res *= v;
          res %= 1_000_000_007;
          res *= v;
          res %= 1_000_000_007;
          return res;
      }
  
      static void sort(int[] a) {
          ArrayList<Integer> l = new ArrayList<>(a.length);
          for (int i : a) {
              l.add(i);
          }
          Collections.sort(l);
          for (int i = 0; i < a.length; i++) {
              a[i] = l.get(i);
          }
      }
  
      //-----------PrintWriter for faster output---------------------------------
      public static FastIO io = new FastIO();
  
      //-----------MyScanner class for faster input----------
      static class FastIO extends PrintWriter {
          private InputStream stream;
          private byte[] buf = new byte[1 << 16];
          private int curChar, numChars;
  
          // standard input
          public FastIO() {
              this(System.in, System.out);
          }
  
          public FastIO(InputStream i, OutputStream o) {
              super(o);
              stream = i;
          }
  
          // file input
          public FastIO(String i, String o) throws IOException {
              super(new FileWriter(o));
              stream = new FileInputStream(i);
          }
  
          // throws InputMismatchException() if previously detected end of file
          private int nextByte() {
              if (numChars == -1) {
                  throw new InputMismatchException();
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars == -1) {
                      return -1; // end of file
                  }
              }
              return buf[curChar++];
          }
  
          // to read in entire lines, replace c <= ' '
          // with a function that checks whether c is a line break
          public String next() {
              int c;
              do {
                  c = nextByte();
              } while (c <= ' ');
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = nextByte();
              } while (c > ' ');
              return res.toString();
          }
  
          public String nextLine() {
              int c;
              do {
                  c = nextByte();
              } while (c < '\n');
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = nextByte();
              } while (c > '\n');
              return res.toString();
          }
  
          public int nextInt() { // nextLong() would be implemented similarly
              int c;
              do {
                  c = nextByte();
              } while (c <= ' ');
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = nextByte();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res = 10 * res + c - '0';
                  c = nextByte();
              } while (c > ' ');
              return res * sgn;
          }
  
          public long nextLong() { // nextLong() would be implemented similarly
              int c;
              do {
                  c = nextByte();
              } while (c <= ' ');
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = nextByte();
              }
              long res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res = 10 * res + c - '0';
                  c = nextByte();
              } while (c > ' ');
              return res * sgn;
          }
  
          public double nextDouble() {
              return Double.parseDouble(next());
          }
      }
  //--------------------------------------------------------
  }