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 {
  	public static void main(String[] args) throws IOException 
  	{ 
  		FastScanner f = new FastScanner(); 
  		int ttt=1;
  		ttt=f.nextInt();
  		PrintWriter out=new PrintWriter(System.out);
  		for(int tt=0;tt<ttt;tt++) {
  			int n=f.nextInt();
  			int K=f.nextInt();
  			int mod = 1000000007;
  			long ans = 0;
  			long ge = n % 2 == 0 ? 1 : 0;
  			long eq = (n % 2 == 1 ? 1 : 0) + pow(2, n-1, mod) - (n % 2 == 1 ? 0 : 1);
  			for(int d = K-1;d >= 0;d--){
  				ans += pow(eq, K-1-d, mod) * ge % mod * pow(2, (long)n*d, mod);
  				ans %= mod;
  			}
  			ans += pow(eq, K, mod);
  			ans %= mod;
  			out.println(ans);
  		}
  		out.close();
  	} 
  	public static long pow(long a, long n, long mod) {
  		//		a %= mod;
  		long ret = 1;
  		int x = 63 - Long.numberOfLeadingZeros(n);
  		for (; x >= 0; x--) {
  			ret = ret * ret % mod;
  			if (n << 63 - x < 0) ret = ret * a % mod;
  		}
  		return ret;
  	}
   
  	static void sort(int[] p) {
          ArrayList<Integer> q = new ArrayList<>();
          for (int i: p) q.add( i);
          Collections.sort(q);
          for (int i = 0; i < p.length; i++) p[i] = q.get(i);
      }
  	static class FastScanner {
  		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st=new StringTokenizer("");
  		String next() {
  			while (!st.hasMoreTokens())
  				try {
  					st=new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			return st.nextToken();
  		}
  		
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  		int[] readArray(int n) {
  			int[] a=new int[n];
  			for (int i=0; i<n; i++) a[i]=nextInt();
  			return a;
  		}
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  		double nextDouble() {
  			return Double.parseDouble(next());
  		}
  		long[] readLongArray(int n) {
  			long[] a=new long[n];
  			for (int i=0; i<n; i++) a[i]=nextLong();
  			return a;
  		}
  	}
  }