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.math.BigInteger;
  import java.nio.charset.StandardCharsets;
  import java.nio.file.Files;
  import java.nio.file.Paths;
  import java.util.*;
  import java.util.stream.Collectors;
  
  public class Solution {
    // @formatter:off
    private static final String inputPath="src/input.txt", expectedPath="src/expected.txt", outputPath="src/output.txt";
    private static int readInt() throws Exception {return Integer.parseInt(br.readLine().trim());}
    private static long readLong() throws Exception {return Long.parseLong(br.readLine().trim());}
    private static int[] readIntArray() throws Exception { String line = br.readLine(); if (line == null || line.isEmpty()) return null; String[] lines = line.trim().split(" "); int n = Integer.parseInt(lines[0]);
      int[] nums = new int[n]; for (int i = 0; i < n; i++) {nums[i] = Integer.parseInt(lines[i + 1]);} return nums; }
    private static int[] readIntArray(int n) throws Exception { int[] nums = new int[n]; String[] lines = br.readLine().trim().split(" "); for (int i = 0; i < n; i++) { nums[i] = Integer.parseInt(lines[i]); } return nums; }
    private static long[] readLongArray(int n) throws Exception { long[] nums = new long[n]; String[] lines = br.readLine().trim().split(" "); for (int i = 0; i < n; i++) { nums[i] = Long.parseLong(lines[i]);} return nums; }
    private static String[] readStringArray(int n) throws Exception { String[] nums = new String[n]; for (int i = 0; i < n; i++) { nums[i] = br.readLine(); } return nums; }
    private static void printArrayInline(int[] nums) throws Exception {for (int i = 0; i < nums.length - 1; i++) {bw.write(nums[i] + " ");}bw.write(nums[nums.length - 1] + "\n");}
    private static void printArrayInline(long[] nums) throws Exception {for (int i = 0; i < nums.length - 1; i++) {bw.write(nums[i] + " ");}bw.write(nums[nums.length - 1] + "\n");}
    private static <T> void printListInLine(List<T> nums) throws Exception {for (int i = 0; i < nums.size() - 1; i++) {bw.write(nums.get(i).toString() + " ");} bw.write(nums.get(nums.size() - 1) + "\n");}
    private static <T> void printListMultiLine(List<T> nums) throws Exception {for (T num : nums) bw.write(num.toString() + "\n");}
    private static void printArrayMultiLine(int[] nums) throws Exception {for (int num : nums) bw.write(num + "\n");}
    private static int parseInt(String str) { return Integer.parseInt(str.trim()); }
    private static int parseInt(String[] str, int i) { return Integer.parseInt(str[i].trim()); }
    private static long parseLong(String str) { return Long.parseLong(str.trim());}
    private static long parseLong(String[] str, int i) {return Long.parseLong(str[i].trim());}
    private static int[] makeRandomArray(int size, int lower, int upper) {Random random = new Random(System.currentTimeMillis());int[] nums = new int[size];for (int i = 0; i < size; i++) {nums[i] = random.nextInt(upper - lower + 1) + lower;}return nums;}
    private static long[] makeRandomLongArray(int size, int lower, int upper) {Random random = new Random(System.currentTimeMillis());long[] nums = new long[size];for (int i = 0; i < size; i++){nums[i] = random.nextInt(upper - lower + 1) + lower;}return nums;}
    private List<Integer>[] makeGraph(int n) {List<Integer>[] graph = new ArrayList[n];for(int i = 0; i < n; i ++) {graph[i] = new ArrayList<>();}return graph;}
    private Set<Integer>[] makeSetGraph(int n) {Set<Integer>[] graph = new HashSet[n];for(int i = 0; i < n; i ++) {graph[i] = new HashSet<>();}return graph;}
    static CustomReader br = new CustomReader(new InputStreamReader(System.in));
    static PrintWriter bw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static { try { String env = System.getProperty("env-jay"); if (env != null && env.equals("jay")) { br = new CustomReader(new FileReader(inputPath)); bw = new PrintWriter(new BufferedWriter(new FileWriter(outputPath, false))); }} catch (Throwable e) {}}
    private static void test() throws Exception {
      try {String env = System.getProperty("env-jay");if (env != null && env.equals("jay")) {List<String> output = Files.readAllLines(Paths.get(outputPath), StandardCharsets.UTF_8);List<String> expected = Files.readAllLines(Paths.get(expectedPath), StandardCharsets.UTF_8);
        for(int line = 0; line < Math.max(output.size(), expected.size()); line ++) {if(line == output.size()) {System.err.println(String.format("Line[%d], There is no extra guess.\nExpected:[%s]", line, expected.get(line)));System.exit(-1);}
          if (line == expected.size()) {System.err.println(String.format( "Line[%d], There is no guess.\nOutput:[%s]" , line + 1, output.get(line))); System.exit(-1);}String ans = expected.get(line), guess = output.get(line);
          if (!ans.equals(guess)) {System.err.println(String.format("Line[%d], Wrong guess.\nAnswer:[%s]\nGuess:[%s]", line + 1, ans, guess));System.exit(-2);}}}} catch (Throwable e) {}}
    static class CustomReader {BufferedReader br;StringTokenizer st;public CustomReader(){br = new BufferedReader(new InputStreamReader(System.in));}public CustomReader(Reader in){br = new BufferedReader(in);}
      String next() throws Exception{while (st == null || !st.hasMoreElements()) {st = new StringTokenizer(br.readLine());}return st.nextToken();}int nextInt() throws Exception { return Integer.parseInt(next()); }
      long nextLong() throws Exception { return Long.parseLong(next()); }double nextDouble() throws Exception{return Double.parseDouble(next());}String readLine() throws Exception{return br.readLine();} void close()throws Exception{br.close();}}
    // @formatter:on
  
    public static void main(String[] args) throws Exception {
      int testCases = br.nextInt();
      for (int iter = 1; iter <= testCases; iter++) {
        int n = br.nextInt(), k = br.nextInt();
        bw.println(solve(n, k));
      }
      bw.flush();
      bw.close();
      br.close();
      test();
    }
  
    static long mod = 1000000007;
  
    private static int solve(int n, int k) {
      if(k == 0) return 1;
      if(n == 1) return (int)powMod(k);
      int[] memo = new int[k + 1];
      int t = (int)powMod(n - 1);
      memo[0] = (int)add(t, n % 2);
      if(n % 2 == 0) {
        for(int i = 1; i < k; i++) {
          memo[i] = (int)add(powMod(powMod(i), n), multiply((t - 1) % mod, memo[i - 1]));
        }
      } else {
        for(int i = 1; i < k; i++) {
          memo[i] = (int)multiply((t + 1) % mod, memo[i - 1]);
        }
      }
      return memo[k - 1];
    }
  
    public static long powMod(long exponent) {
      return powMod(2, exponent);
    }
  
    public static long powMod(long base, long exponent) {
      base %= mod;
      long ans = 1;
      if ((exponent & 1) == 1) {
        ans = base;
      }
      while (exponent > 1)  {
        exponent >>= 1;
        base = (base * base) % mod;
        if ((exponent & 1) == 1)  {
          ans = (ans * base) % mod;
        }
      }
      return ans;
    }
  
    public static long multiply(long one, long another) {
      return (one * another) % mod;
    }
  
    public static long add(long one, long another) {
      return (one + another ) % mod;
    }
  }
  