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 Main {
      public static long mod = 1000000007;
  
      public static void main(String[] args) {
          PrintWriter pr = new PrintWriter(System.out);
          FastScanner input = new FastScanner();
          int num = input.nextInt();
  
          for (int i = 0; i < num; i ++) {
            int len = input.nextInt();
            int dig = input.nextInt();
  
            if (dig == 0) System.out.println(1);
            else {
              long hold = modexp(2, len - 1);
              if (len % 2 == 1) System.out.println(modexp(hold + 1, dig));
              else {
                hold -= 1;
                long ans = modexp(hold, dig);
                long hi = 1;
                long bye = modexp(2, len);
  
                for (long k = dig - 1; k >= 0; k --) {
                  if (k == 0) ans += hi;
                  else ans += (long)(modexp(hold, k) * hi) % mod;
                  ans %= mod;
                  hi = (hi * bye) % mod;
                }
                System.out.println(ans);
              }
            }
          }
      }
  
  
      public static class point implements Comparable<point> {
        public int x, y;
        public point(int x, int y) {
          this.x = x;
          this.y = y;
        }
  
        @Override public int compareTo(point a) {
          if (this.x > a.x) return 1;
          else if (this.x == a.x) return 0;
          else return -1;
        }
      }
  
  public static long modexp(long a, long b) {return modexp(a, b, mod);}
  
  	public static long modexp(long a, long b, long m) {
  		long res = 1;
  		while (b > 0) {
  			if (b%2 != 0) res = (res*a)%m;
  			a = (a*a)%m;
  			b /= 2;
  		}
  		return res;
  	}
  
      public static int gcd(int a, int b) {
        if (a == 0) return b;
        else return gcd(b % a, a);
      }
  
      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()); }
      }
  
  
  }
  