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.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.util.Arrays;
  import java.util.Random;
  import java.util.StringTokenizer;
  
  public final class C {
  
      private static final int MOD = (int) (1e9 + 7);
  
      private static class Combinations {
          long[] factorial;
          long[] facInverse;
          long[] inverse;
  
          Combinations(int n) {
              final int MAX = n + 2;
              factorial = new long[MAX];
              facInverse = new long[MAX];
              inverse = new long[MAX];
              factorial[0] = factorial[1] = 1;
              facInverse[0] = facInverse[1] = 1;
              inverse[1] = 1;
              for (int i = 2; i < MAX; i++) {
                  factorial[i] = factorial[i - 1] * i % MOD;
                  final long inv = inverse[i] = MOD - inverse[MOD % i] * (MOD / i) % MOD;
                  facInverse[i] = facInverse[i - 1] * inv % MOD;
              }
          }
  
          long nck(int n, int k) {
              if (n < k) { return 0; }
              if (n < 0 || k < 0) { return 0; }
              return factorial[n] * (facInverse[k] * facInverse[n - k] % MOD) % MOD;
          }
  
          // combinations with repetition
          long ncr(int n, int k) {
              return nck(n + k - 1, k);
          }
  
          // permutations with repetition
          long npk(int n, int k) {
              if (n < k) { return 0; }
              if (n < 0 || k < 0) { return 0; }
              return factorial[n] * facInverse[n - k] % MOD;
          }
  
          long modPow(long a, long n) {
              long res = 1;
              while (n > 0) {
                  if (n % 2 != 0) {
                      res = res * a % MOD;
                  }
                  a = a * a % MOD;
                  n /= 2;
              }
              return res;
          }
      }
  
      public static void main(String[] args) {
          final FastScanner fs = new FastScanner();
          final Combinations comb = new Combinations((int) (2e5 + 5));
          final int t = fs.nextInt();
          for (int test = 0; test < t; test++) {
              final int n = fs.nextInt();
              final int k = fs.nextInt();
              long single = 0;
              if (n % 2 != 0) {
                  single++;
              }
              for (int i = 0; i < n; i += 2) {
                  single = (single + comb.nck(n, i)) % MOD;
              }
              long res = comb.modPow(single, k);
              if (n % 2 == 0) {
                  long equal = 1;
                  for (int i = 0; i < k; i++) {
                      final long greater = comb.modPow(2, n);
                      long add = comb.modPow(greater, k - 1 - i);
                      add = (add * equal) % MOD;
                      res = (res + add) % MOD;
                      equal = (equal * single) % MOD;
                  }
              }
              System.out.println(res);
          }
      }
  
      static final class Utils {
          private static class Shuffler {
              private static void shuffle(int[] x) {
                  final Random r = new Random();
  
                  for (int i = 0; i <= x.length - 2; i++) {
                      final int j = i + r.nextInt(x.length - i);
                      swap(x, i, j);
                  }
              }
  
              private static void shuffle(long[] x) {
                  final Random r = new Random();
  
                  for (int i = 0; i <= x.length - 2; i++) {
                      final int j = i + r.nextInt(x.length - i);
                      swap(x, i, j);
                  }
              }
  
              private static void swap(int[] x, int i, int j) {
                  final int t = x[i];
                  x[i] = x[j];
                  x[j] = t;
              }
  
              private static void swap(long[] x, int i, int j) {
                  final long t = x[i];
                  x[i] = x[j];
                  x[j] = t;
              }
          }
  
          public static void shuffleSort(int[] arr) {
              Shuffler.shuffle(arr);
              Arrays.sort(arr);
          }
  
          public static void shuffleSort(long[] arr) {
              Shuffler.shuffle(arr);
              Arrays.sort(arr);
          }
  
          private Utils() {}
      }
  
      static class FastScanner {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          StringTokenizer st = new StringTokenizer("");
  
          private String next() {
              while (!st.hasMoreTokens()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      //noinspection CallToPrintStackTrace
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          int[] nextIntArray(int n) {
              final int[] a = new int[n];
              for (int i = 0; i < n; i++) { a[i] = nextInt(); }
              return a;
          }
  
          long[] nextLongArray(int n) {
              final long[] a = new long[n];
              for (int i = 0; i < n; i++) { a[i] = nextLong(); }
              return a;
          }
      }
  }
  