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: #include <bits/stdc++.h>
  using namespace std;
  template <class c>
  struct rge {
    c b, e;
  };
  template <class c>
  rge<c> range(c i, c j) {
    return rge<c>{i, j};
  }
  template <class c>
  auto dud(c* x) -> decltype(cerr << *x, 0);
  template <class c>
  char dud(...);
  struct debug {
    template <class c>
    debug& operator<<(const c&) {
      return *this;
    }
  };
  vector<char*> tokenizer(const char* args) {
    char* token = new char[111];
    strcpy(token, args);
    token = strtok(token, ", ");
    vector<char*> v({token});
    while (token = strtok(NULL, ", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
  }
  void debugg(vector<char*> args) { cerr << "\b "; }
  template <typename Head, typename... Tail>
  void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back();
    debugg(args, T...);
  }
  const double PI = acos(-1);
  const long long mod = 1e9 + 7;
  long long bin_pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = (res * a) % mod;
      a = (a * a) % mod;
      b >>= 1;
    }
    return res;
  }
  long long n;
  vector<long long> dp;
  long long sol(long long k) {
    {};
    if (k == 1) {
      if (n % 2 == 0)
        return bin_pow(2, n - 1);
      else
        return (1 + bin_pow(2, n - 1)) % mod;
    }
    if (dp[k] != -1) return dp[k];
    dp[k] = 0;
    if (n % 2 == 0) {
      dp[k] += bin_pow(2, k * n - n);
      dp[k] %= mod;
      dp[k] += (((bin_pow(2, n - 1) - 1 + mod) % mod) * sol(k - 1)) % mod;
      dp[k] %= mod;
    } else {
      dp[k] += sol(k - 1);
      dp[k] %= mod;
      dp[k] += (bin_pow(2, n - 1) * sol(k - 1)) % mod;
      dp[k] %= mod;
    }
    return dp[k];
  }
  int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int test = 1;
    cin >> test;
    while (test--) {
      long long k;
      cin >> n >> k;
      dp = vector<long long>(k + 1, -1);
      dp[0] = 1;
      cout << sol(k) << "\n";
    }
    return 0;
  }
  