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: /*Everything is Hard 
   * Before Easy 
   * Jai Mata Dii 
   */ 
   
  import java.util.*;
  import java.io.*; 
    
  public class Main {
  	static class FastReader{ BufferedReader br;StringTokenizer st;public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}int nextInt(){ return Integer.parseInt(next());}long nextLong(){return Long.parseLong(next());}double nextDouble(){return Double.parseDouble(next());}String nextLine(){String str = ""; try{str = br.readLine(); } catch (IOException e) {e.printStackTrace();} return str; }} 
  	static long mod = (long)(1e9+7); 
  	// static long mod = 998244353; 
  //	 static Scanner sc = new Scanner(System.in); 
  	static FastReader sc = new FastReader(); 
  	static PrintWriter out = new PrintWriter(System.out);
  	public static void main (String[] args) { 
  		int ttt = 1;
  		ttt = sc.nextInt();
  		precompute();
  		z :for(int tc=1;tc<=ttt;tc++){
  			int n = sc.nextInt();
  			int k = sc.nextInt();
  			if(k == 0) {
  				out.write(1+"\n");
  				continue;
  			}
  			long ans = 0;
  			long pre = 0;
  			for(int r=0;r<n;r+=2) {
  				pre = (pre + ((fac[(int)n] * power(fac[(int)(n-r)],mod-2,mod))%mod * power(fac[(int)r],mod-2,mod))%mod)%mod;
  			}
  //			System.out.println(pre);
  			if(n%2!=0) {
  				pre = (pre+1)%mod;
  				for(int i=0;i<k;i++) {
  					long cans = (pre)%mod;
  					if(ans!=0) ans = (cans * ans)%mod;
  					else ans = (cans)%mod;
  				}
  			}
  			else {
  				long upTill = 1;
  				for(int i=0;i<n;i++) {
  					upTill = (upTill*2)%mod;
  				}
  				long mul = upTill;
  				for(int i=0;i<k;i++) {
  					long cans = (pre)%mod;
  					if(ans!=0) {
  						cans = (cans)%mod;
  						ans = (cans * ans)%mod;
  						ans = (ans + upTill)%mod;
  						upTill = (upTill*mul)%mod;
  					}
  					else {
  						ans = (cans+1)%mod;
  					}
  				}
  			}
  			out.write(ans+"\n");
  		}
  		out.close();
  	}
  	static long fac[] = new long[200006];
  	
  	static void precompute() {
  		int n = 200005;
  		fac[0] = 1;
  		for(int i=1;i<=n;i++)
  			fac[i] = (i * fac[i-1])%mod;
  	}
  	
  	static long power(long base, long p, long mod2) {
  		
  		long ans = 1;
  		while(p!=0) {
  			if(p%2==0) {
  				base = (base*base)%mod2;
  				p/=2;
  			}
  			else {
  				ans = (ans*base)%mod2;
  				p-=1;
  			}
  		}
  		return (int) (ans%mod2);
  	}
  	static long pow(long a, long b){long ret = 1;while(b>0){if(b%2 == 0){a = (a*a)%mod;b /= 2;}else{ret = (ret*a)%mod;b--;}}return ret%mod;}
  	static long gcd(long a,long b){if(b==0) return  a; return gcd(b,a%b); } 
  	private static void sort(int[] a) {List<Integer> k = new ArrayList<>();for(int val : a) k.add(val);Collections.sort(k);for(int i=0;i<a.length;i++) a[i] = k.get(i);} 
  	private static void ini(List<Integer>[] tre2){for(int i=0;i<tre2.length;i++){tre2[i] = new ArrayList<>();}} 
  	private static void init(List<int[]>[] tre2){for(int i=0;i<tre2.length;i++){tre2[i] = new ArrayList<>();}} 
  	private static void sort(long[] a) {List<Long> k = new ArrayList<>();for(long val : a) k.add(val);Collections.sort(k);for(int i=0;i<a.length;i++) a[i] = k.get(i);} 
  }
  