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.util.*;
  import java.io.*;
  import java.lang.*;
  import java.util.jar.JarEntry;
  
  public class Main{
      /* || श्री गणेशाय नमः ||
         @𝐚𝐮𝐭𝐡𝐨𝐫 𝐉𝐢𝐠𝐚𝐫 𝐍𝐚𝐢𝐧𝐮𝐣𝐢
         𝐒𝐕𝐍𝐈𝐓- 𝐒𝐮𝐫𝐚𝐭
      */
      public static void main(String args[]){
          InputReader in=new InputReader(System.in);
          TASK solver = new TASK();
          int t=1;
          t = in.nextInt();
          for(int i=1;i<=t;i++)
          {
              solver.solve(in,i);
          }
      }
      static class TASK {
          static int mod=1000000007;
  
          static long pow(int n)
          {
              if(n==0)
                  return 1;
              long d = pow(n/2);
              long ans = (d*1l*d)%mod;
              if(n%2==1)
                  ans=(ans*2l)%mod;
              return ans;
  
          }
          static long dp[][];
          void solve(InputReader in, int testNumber) {
              int n = in.nextInt();
              int k = in.nextInt();
              if(k==0)
              {
                  System.out.println(1);
                  return;
              }
              dp=new long[k][2];
              long sum2=(pow(n-1))%mod;
              long sum1=pow(n);
              if(n%2==0) {
                  dp[k-1][0] =sum2;
                  dp[k-1][1]=sum1;
                  for(int i=k-2;i>=0;i--)
                  {
                      dp[i][0]=(dp[i+1][1] + ((sum2-1)*1l*dp[i+1][0])%mod)%mod;
                      dp[i][1]=(sum1*1l*dp[i+1][1])%mod;
                  }
                  System.out.println((dp[0][0])%mod);
              }
              else
              {
                  dp[k-1][0]=sum2+1;
                  for(int i=k-2;i>=0;i--)
                  {
                      dp[i][0]=((sum2+1)*1l*dp[i+1][0])%mod;
                  }
  
                  System.out.println((dp[0][0])%mod);
              }
  
  
  
          }
      }
  
  
      static class pair{
          int x;
          int y;
          pair(int x,int y)
          {
              this.x=x;
              this.y=y;
          }
      }
      static class bb{
          int a[] = new int[5];
      }
  
      static class Maths {
          static long gcd(long a, long b) {
              if (a < b)
                  return gcd(b,a);
              if (b == 0)
                  return a;
              else
                  return gcd(b,a%b);
          }
          public static long lcm(long a, long b) {
              return (a * b) / gcd(a, b);
          }
  
      }
      static class InputReader {
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private SpaceCharFilter filter;
          public InputReader(InputStream stream) {
              this.stream = stream;
          }
          public int read() {
              if (numChars == -1)
                  throw new InputMismatchException();
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0)
                      return -1;
              }
              return buf[curChar++];
          }
          public String nextLine() {
              BufferedReader br = new BufferedReader(new
                      InputStreamReader(System.in));
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
          public int nextInt() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              while (!isSpaceChar(c));
              return res * sgn;
          }
          public long nextLong() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              do {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              while (!isSpaceChar(c));
              return res * sgn;
          }
          public double nextDouble() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.') {
                  if (c == 'e' || c == 'E')
                      return res * Math.pow(10, nextInt());
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.') {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c)) {
                      if (c == 'e' || c == 'E')
                          return res * Math.pow(10, nextInt());
                      if (c < '0' || c > '9')
                          throw new InputMismatchException();
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
          public String readString() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              StringBuilder res = new StringBuilder();
              do {
                  res.appendCodePoint(c);
                  c = read();
              }
              while (!isSpaceChar(c));
              return res.toString();
          }
          public boolean isSpaceChar(int c) {
              if (filter != null)
                  return filter.isSpaceChar(c);
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c
                      == -1;
          }
          public String next() {
              return readString();
          }
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
  }
  
  