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 C_1557 {
  	
  	static int mod = (int)1e9+7;
  	static int k, sumall, sumeven1;
  	static int[][] memo;
  	
  	public static int dp(int i, int prev) {
  		if(i == k)
  			return 1;
  		if(memo[i][prev] != -1)
  			return memo[i][prev];
  		
  		int sum = 0;
  		if(prev == 0) {
  			sum = dp(i + 1, 1);
  			int sum2 = (int)((1l * sumeven1 * dp(i + 1, 0)) % mod);
  			sum = (int)((1l * sum + sum2) % mod);
  		} else {
  			sum = (int)((1l * sumall * dp(i + 1, 1)) % mod);
  		}
  		return memo[i][prev] = sum;
  	}
  	
  	public static int pow(int a, int b, int m) {
  		int res = 1;
  		while(b > 0) {
  			if((b & 1) == 1)
  				res = (int)((1l * res * a) % m);
  			a = (int)((1l * a * a) % m);
  			b >>= 1;
  		}
  		return res;
  	}
  	
  	public static void main(String[] args) throws Exception {
  		Scanner sc = new Scanner(System.in);
  		PrintWriter pw = new PrintWriter(System.out);
  		
  		int[] fac = new int[(int)2e5 + 1];
  		fac[0] = 1;
  		for(int i = 1; i < fac.length; i++)
  			fac[i] = (int)((1l * i * fac[i - 1]) % mod);
  		
  		int[] inv = new int[fac.length];
  		for(int i = 0; i < inv.length; i++)
  			inv[i] = pow(fac[i], mod - 2, mod);
  		
  		int t = sc.nextInt();
  		while(t-->0) {
  			int n = sc.nextInt();
  			k = sc.nextInt();
  			int sumeven = 0;
  			for(int i = 0; i <= n; i += 2)
  				sumeven = (int)((1l * sumeven + ((1l * fac[n] * ((1l * inv[n - i] * inv[i]) % mod)) % mod)) % mod);
  			if(n % 2 == 1) {
  				sumeven = (int)((1l * sumeven + 1) % mod);
  				sumeven = pow(sumeven, k, mod);
  				pw.println(sumeven);
  			} else {
  				sumall = 0;
  				for(int i = 0; i <= n; i++)
  					sumall = (int)((1l * sumall + ((1l * fac[n] * ((1l * inv[n - i] * inv[i]) % mod)) % mod)) % mod);
  				sumeven1 = (int)(((1l * (1l * sumeven - 1) % mod) + mod) % mod);
  				
  				memo = new int[k][2];
  				for(int[] i : memo)
  					Arrays.fill(i, -1);
  				
  				pw.println(dp(0, 0));
  			}
  		}
  		
  		pw.flush();
  	}
  
  	public static class Scanner {
  		StringTokenizer st;
  		BufferedReader br;
  
  		public Scanner(InputStream system) {
  			br = new BufferedReader(new InputStreamReader(system));
  		}
  
  		public Scanner(String file) throws Exception {
  			br = new BufferedReader(new FileReader(file));
  		}
  
  		public String next() throws IOException {
  			while (st == null || !st.hasMoreTokens())
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  
  		public String nextLine() throws IOException {
  			return br.readLine();
  		}
  
  		public int nextInt() throws IOException {
  			return Integer.parseInt(next());
  		}
  
  		public double nextDouble() throws IOException {
  			return Double.parseDouble(next());
  		}
  
  		public char nextChar() throws IOException {
  			return next().charAt(0);
  		}
  
  		public long nextLong() throws IOException {
  			return Long.parseLong(next());
  		}
  
  		public int[] nextIntArray(int n) throws IOException {
  			int[] array = new int[n];
  			for (int i = 0; i < n; i++)
  				array[i] = nextInt();
  			return array;
  		}
  
  		public Integer[] nextIntegerArray(int n) throws IOException {
  			Integer[] array = new Integer[n];
  			for (int i = 0; i < n; i++)
  				array[i] = new Integer(nextInt());
  			return array;
  		}
  
  		public long[] nextLongArray(int n) throws IOException {
  			long[] array = new long[n];
  			for (int i = 0; i < n; i++)
  				array[i] = nextLong();
  			return array;
  		}
  
  		public double[] nextDoubleArray(int n) throws IOException {
  			double[] array = new double[n];
  			for (int i = 0; i < n; i++)
  				array[i] = nextDouble();
  			return array;
  		}
  
  		public static int[] shuffle(int[] a) {
  			int n = a.length;
  			Random rand = new Random();
  			for (int i = 0; i < n; i++) {
  				int tmpIdx = rand.nextInt(n);
  				int tmp = a[i];
  				a[i] = a[tmpIdx];
  				a[tmpIdx] = tmp;
  			}
  			return a;
  		}
  
  		public boolean ready() throws IOException {
  			return br.ready();
  		}
  
  		public void waitForInput() throws InterruptedException {
  			Thread.sleep(3000);
  		}
  	}
  }
  