#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long sz = 1e6 + 5;
vector<long long> fac, ifac;
vector<int> prime;
vector<long long> pri;
long long mpow(long long a, long long b = mod - 2, long long m = mod) {
  long long res = 1;
  a %= m;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
  }
  return res;
}
void init() {
  fac.resize(sz, 1);
  ifac.resize(sz);
  for (long long i = 2; i < sz; i++) fac[i] = (fac[i - 1] * i) % mod;
  ifac[sz - 1] = mpow(fac[sz - 1]);
  for (long long i = sz - 2; i >= 0; i--)
    ifac[i] = (ifac[i + 1] * (i + 1)) % mod;
  prime.resize(sz);
  for (int i = 2; i < sz; i++) prime[i] = i;
  for (long long i = 2; i * i < sz; i++) {
    if (prime[i] != i) continue;
    for (long long j = i * i; j < sz; j += i)
      if (prime[j] == j) prime[j] = i;
  }
  for (long long i = 2; i < sz; i++) {
    if (prime[i] == i) pri.push_back(i);
  }
}
long long nCr(long long n, long long r) {
  if (n <= 0 || r < 0) return 0;
  if (n < r) return 0;
  return (fac[n] * (ifac[r] * ifac[n - r] % mod)) % mod;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
void solve() {
  long long n, k;
  cin >> n >> k;
  long long res = 0;
  vector<long long> dp(k + 1, 1);
  for (long long i = 1; i <= k; i++) {
    long long poss = 0;
    if (n % 2 == 0) {
      long long x = dp[i - 1];
      x = (x * mpow(2ll, (k - i) * n)) % mod;
      res = (res + x) % mod;
      poss = (mpow(2ll, n - 1) - 1 + mod) % mod;
    } else
      poss = (mpow(2ll, n - 1) + 1) % mod;
    dp[i] = (dp[i - 1] * poss) % mod;
  }
  res = (res + dp[k]) % mod;
  cout << res << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  init();
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long sz = 1e6 + 5;
vector<long long> fac, ifac;
vector<int> prime;
vector<long long> pri;
long long mpow(long long a, long long b = mod - 2, long long m = mod) {
  long long res = 1;
  a %= m;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
  }
  return res;
}
void init() {
  fac.resize(sz, 1);
  ifac.resize(sz);
  for (long long i = 2; i < sz; i++) fac[i] = (fac[i - 1] * i) % mod;
  ifac[sz - 1] = mpow(fac[sz - 1]);
  for (long long i = sz - 2; i >= 0; i--)
    ifac[i] = (ifac[i + 1] * (i + 1)) % mod;
  prime.resize(sz);
  for (int i = 2; i < sz; i++) prime[i] = i;
  for (long long i = 2; i * i < sz; i++) {
    if (prime[i] != i) continue;
    for (long long j = i * i; j < sz; j += i)
      if (prime[j] == j) prime[j] = i;
  }
  for (long long i = 2; i < sz; i++) {
    if (prime[i] == i) pri.push_back(i);
  }
}
long long nCr(long long n, long long r) {
  if (n <= 0 || r < 0) return 0;
  if (n < r) return 0;
  return (fac[n] * (ifac[r] * ifac[n - r] % mod)) % mod;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
void solve() {
  long long n, k;
  cin >> n >> k;
  long long res = 0;
  vector<long long> dp(k + 1, 1);
  for (long long i = 1; i <= k; i++) {
    long long poss = 0;
    if (n % 2 == 0) {
      long long x = dp[i - 1];
      x = (x * mpow(2ll, (k - i) * n)) % mod;
      res = (res + x) % mod;
      poss = (mpow(2ll, n - 1) - 1 + mod) % mod;
    } else
      poss = (mpow(2ll, n - 1) + 1) % mod;
    dp[i] = (dp[i - 1] * poss) % mod;
  }
  res = (res + dp[k]) % mod;
  cout << res << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  init();
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

```