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 {
  	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	static StringTokenizer st;
  	static PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));
  	static String readLine() throws IOException {
  		return br.readLine();
  	}
  	static String next() throws IOException {
  		while (st == null || !st.hasMoreTokens())
  			st = new StringTokenizer(readLine());
  		return st.nextToken();
  	}
  	static int readInt() throws IOException {
  		return Integer.parseInt(next());
  	}
  	static long readLong() throws IOException {
  		return Long.parseLong(next());
  	}
  	static double readDouble() throws IOException {
  		return Double.parseDouble(next());
  	}
  	static char readChar() throws IOException {
  		return next().charAt(0);
  	}
  	static class Pair implements Comparable<Pair> {
  		int f, s;
  		Pair(int f, int s) {
  			this.f = f; this.s = s;
  		}
  		public int compareTo(Pair other) {
  			if (this.f != other.f) return this.f - other.f;
  			return this.s - other.s;
  		}
  	}
  	final static int mod = (int)1e9 + 7;
  	static long pow(long b, long p) {
  		long ret = 1;
  		while (p > 0) {
  			if ((p&1) == 1) ret = b*ret%mod;
  			b = b*b%mod;
  			p >>= 1;
  		}
  		return ret;
  	}
  	static long fac[], inv[], psa[][];
  	static long C(int n, int k) {
  		return fac[n]*(inv[k]*inv[n - k]%mod)%mod;
  	}
  	static void solve() throws IOException {
  		int n = readInt(), k = readInt();
  		fac = new long[n + 1];
  		inv = new long[n + 1];
  		fac[0] = inv[0] = 1;
  		for (int i = 1; i <= n; ++i) {
  			fac[i] = i*fac[i - 1]%mod;
  			inv[i] = pow(fac[i], mod - 2);
  		}
  		psa = new long[2][n + 1];
  		for (int j = 0; j <= 1; ++j) {
  			for (int i = 0; i <= n; ++i) {
  				if ((i&1) == j) psa[j][i] = C(n, i);
  				if (i > 0) psa[j][i] = (psa[j][i] + psa[j][i - 1])%mod;
  			}
  		}
  		long mul = (psa[0][n - 1] + psa[1][n] - psa[1][n - 1] + mod)%mod, ans = pow(mul, k);
  		for (int i = 1; i <= k; ++i) {
  			//if i is the first bit the differ
  			long add = pow(2, (long)(i - 1)*n);
  			add = add*(psa[0][n] - psa[0][n - 1] + mod)%mod;
  			add = add*pow(mul, k - i)%mod;
  			ans = (ans + add)%mod;
  		}
  		pr.println(ans);
  	}
  	public static void main(String[] args) throws IOException {
  		//solve();
  		for (int t = readInt(); t > 0; --t) solve();
  		pr.close();
  	}
  }
  