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.*;
  public class Main {
      public static void main(String args[])
      {
          FastReader input=new FastReader();
          PrintWriter out=new PrintWriter(System.out);
          int T=input.nextInt();
          while(T-->0)
          {
              int n=input.nextInt();
              int k=input.nextInt();
              long fac[]=new long[n+1];
              fac[0]=1;
              long m=1000000007;
              for(int i=1;i<=n;i++)
              {
                  fac[i]=(fac[i-1]*i)%m;
              }
              if(n%2!=0)
              {
                  long sum=0;
                  for(int i=0;i<=n;i+=2)
                  {
                      long com=comb(fac,n,i,m);
                      sum=(sum+com)%m;
                  }
                  sum=(sum+1)%m;
                  long pro=power(sum,k,m);
                  out.println(pro);
              }
              else
              {
                  if(k==0)
                  {
                      out.println(1);
                  }
                  else
                  {
                      long ans=0;
                      long esum=0;
                      for(int i=0;i<n;i+=2)
                      {
                          long com=comb(fac,n,i,m);
                          esum=(esum+com)%m;
                      }
                      long pow=power(2,n,m);
                      long arrP1[]=new long[k+1];
                      long arrE[]=new long[k+1];
                      arrP1[0]=arrE[0]=1;
                      for(int i=1;i<=k;i++)
                      {
                          arrP1[i]=(arrP1[i-1]*pow)%m;
                          arrE[i]=(arrE[i-1]*esum)%m;
                      }
                      for(int i=k-1;i>=0;i--)
                      {
                          long p1=pow;
                          p1=arrP1[i];
                          int top=k-1-i;
                          long p2=arrE[top];
                          long s=1;
                          if(p1>0) s=(s*p1)%m;
                          if(p2>0) s=(s*p2)%m;
                          ans=(ans+s)%m;
                      }
                      long p1=power(esum,k,m);
                      ans=(ans+p1)%m;
                      out.println(ans);
                  }
              }
          }
          out.close();
      }
      public static long comb(long fac[],int nu,int b,long m)
      {
          long x=fac[nu];
          long y=(fac[b]%m*fac[nu-b]%m)%m;
          long v=power(y,m-2,m);
          long z=(x%m*v%m)%m;
          return z;
      }
      public static long power(long a,long b,long m)
      {
          long res=1;
          while(b>0)
          {
              if(b%2!=0)
              {
                  res=(res%m*a%m)%m;
              }
              b=b/2;
              a=(a%m*a%m)%m;
          }
          return res;
      }
      static class FastReader
      {
          BufferedReader br;
          StringTokenizer st;
          public FastReader()
          {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
          String next()
          {
              while (st == null || !st.hasMoreElements())
              {
                  try
                  {
                      st = new StringTokenizer(br.readLine());
                  }
                  catch (IOException e)
                  {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
          int nextInt()
          {
              return Integer.parseInt(next());
          }
          long nextLong()
          {
              return Long.parseLong(next());
          }
          double nextDouble()
          {
              return Double.parseDouble(next());
          }
          String nextLine()
          {
              String str="";
              try
              {
                  str=br.readLine();
              }
              catch (IOException e)
              {
                  e.printStackTrace();
              }
              return str;
          }
      }
  }