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.*;
  
  public class C {
      public static class IOParser {
          InputStreamReader isr = new InputStreamReader(System.in);
          StringWriter sw = new StringWriter();
          BufferedReader br = new BufferedReader(isr);
          BufferedWriter bw = new BufferedWriter(sw);
  
          void println() throws IOException {
              bw.flush();
              System.out.println(sw.getBuffer());
  
          }
  
          void append(CharSequence csq) throws IOException {
              bw.append(csq);
          }
  
          void print() throws IOException {
              bw.flush();
              System.out.print(sw.getBuffer());
  
          }
  
          String read() throws IOException {
              return br.readLine().trim();
          }
  
          int I(String str) {
              return Integer.parseInt(str);
          }
  
          long L(String str) {
              return Long.parseLong(str);
          }
  
          int nextInt() throws IOException {
              return I(read());
          }
  
          long nextLong() throws IOException {
              return L(read());
          }
  
          String[] readStringArray() throws IOException {
              return read().split(" ");
          }
  
          int[] readIntegerArray() throws IOException {
              String[] arrs = read().split(" ");
              int[] arr = new int[arrs.length];
  
              for (int i = 0; i < arrs.length; i++) {
                  arr[i] = I(arrs[i]);
              }
  
              return arr;
          }
  
          long[] readLongArray() throws IOException {
              String[] arrs = read().split(" ");
              long[] arr = new long[arrs.length];
  
              for (int i = 0; i < arrs.length; i++) {
                  arr[i] = L(arrs[i]);
              }
  
              return arr;
          }
  
      }
  
      static long mod_pow(long x, long n, long m) {
          if (n == 0)
              return 1;
  
          long sm = mod_pow(x, n / 2, m);
  
          if (n % 2 == 0) {
              long ans = ((sm % m) * (sm % m)) % m;
              // System.out.println(ans);
              return ans;
          } else {
              long ans = ((sm % m) * (sm % m)) % m;
              ans = ((ans % m) * (x % m)) % m;
              // System.out.println(ans);
              return ans;
          }
      }
  
      static void solve(int n, int k) {
          long mod = (long) 1e9 + 7;
  
          if (k == 0) {
              System.out.println(1);
              return;
          }
  
          long n_21 = mod_pow(2, n - 1, mod);
          long n2 = (n_21 * 2) % mod;
          if ((n & 1) == 0) { // even
              long cnt = n_21;
              long pow = 1;
              long c3 = n_21 - 1;
              for (int i = 2; i <= k; i++) {
                  pow = ((pow % mod) * (n2 % mod)) % mod;
                  cnt = ((pow % mod) + (c3 % mod * cnt % mod) % mod) % mod;
  
              }
              System.out.println(cnt);
          } else { // odd
              long cnt = mod_pow((n_21 + 1) % mod, k, mod);
              System.out.println(cnt);
          }
      }
  
      public static void main(String[] args) {
          try {
              IOParser iop = new IOParser();
  
              int t = iop.nextInt();
              while (t-- > 0) {
                  int[] nk = iop.readIntegerArray();
                  int n = nk[0], k = nk[1];
                  solve(n, k);
              }
          } catch (Exception e) {
              // TODO: handle exception
          }
      }
  
  }
  