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.*;
  
  public class C1557 {
  
  	static long[] fac, facInv;
  	static final int mod = (int) 1e9 + 7;
  
  	static long modPow(long a, long e) {
  		if (e == 0) {
  			return 1;
  		}
  		long prev = modPow(a, e / 2);
  		if (e % 2 == 0) {
  			return prev * prev % mod;
  		} else {
  			return prev * prev % mod * a % mod;
  		}
  	}
  
  	static long modInv(long x) {
  		return modPow(x, mod - 2);
  	}
  
  	static void preprocess(int n) {
  		fac = new long[n];
  		facInv = new long[n];
  		fac[0] = facInv[0] = 1;
  		for (int i = 1; i < n; i++) {
  			fac[i] = fac[i - 1] * i % mod;
  			facInv[i] = facInv[i - 1] * modInv(i) % mod;
  		}
  	}
  
  	static long nck(int n, int k) {
  		if (n < 0 || k < 0 || k > n) {
  			return 0;
  		}
  		return fac[n] * facInv[k] % mod * facInv[n - k] % mod;
  	}
  
  	public static void main(String[] args) throws IOException {
  		Scanner sc = new Scanner(System.in);
  		PrintWriter pw = new PrintWriter(System.out);
  		preprocess(200100);
  		int t = sc.nextInt();
  		while (t-- > 0) {
  			int n = sc.nextInt();
  			int k = sc.nextInt();
  			long nckSum = 0;
  			for (int i = 0; i < n; i += 2) {
  				nckSum += nck(n, i);
  				nckSum %= mod;
  			}
  			long ans = 1;
  			long fAns = 0;
  			long[] n2 = new long[k + 1]; // n ^ (i * k)
  			n2[0] = 1;
  			long mult = modPow(2, n);
  			for (int i = 1; i < n2.length; i++) {
  				n2[i] = n2[i - 1] * mult % mod;
  			}
  			for (int i = 0; i < k; i++) {
  				if (n % 2 == 0) {
  					fAns += n2[(k - i - 1)] * ans;
  					ans *= nckSum;
  				} else {
  					ans *= (nckSum + 1);
  				}
  				fAns %= mod;
  				ans %= mod;
  			}
  			pw.println((fAns + ans) % mod);
  		}
  		pw.close();
  	}
  
  	static class Scanner {
  		BufferedReader br;
  		StringTokenizer st;
  
  		public Scanner(InputStream s) {
  			br = new BufferedReader(new InputStreamReader(s));
  		}
  
  		public Scanner(FileReader f) {
  			br = new BufferedReader(f);
  		}
  
  		public String next() throws IOException {
  			while (st == null || !st.hasMoreTokens())
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  
  		public int nextInt() throws IOException {
  			return Integer.parseInt(next());
  		}
  
  		public long nextLong() throws IOException {
  			return Long.parseLong(next());
  		}
  
  		public double nextDouble() throws IOException {
  			return Double.parseDouble(next());
  		}
  
  		public int[] nextIntArr(int n) throws IOException {
  			int[] arr = new int[n];
  			for (int i = 0; i < n; i++) {
  				arr[i] = Integer.parseInt(next());
  			}
  			return arr;
  		}
  
  	}
  
  }
  