#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MONKE = 0;
ll inv_mod(ll a, ll m) {
  ll _m = m, q, t, x, y;
  if (m == 1) return 0;
  for (y = 0, x = 1; a > 1; t = y, y = x - q * y, x = t) {
    q = a / m, t = m;
    m = a % m, a = t;
  }
  return x < 0 ? x + _m : x;
}
class modulo_int {
 public:
  ll val;
  static const ll mod = 1e9 + 7;
  modulo_int(ll _val = 0) { val = _val > 0 ? _val % mod : _val % mod + mod; }
  modulo_int operator+(modulo_int rhs) { return modulo_int((val + rhs.val)); }
  modulo_int operator-(modulo_int rhs) { return modulo_int((val - rhs.val)); }
  modulo_int operator*(modulo_int rhs) { return modulo_int((val * rhs.val)); }
  modulo_int operator/(modulo_int rhs) {
    return modulo_int(binpow(rhs, mod - 2) * val);
  }
  void operator+=(modulo_int rhs) { *this = *this + rhs; }
  void operator-=(modulo_int rhs) { *this = *this - rhs; }
  void operator*=(modulo_int rhs) { *this = *this * rhs; }
  void operator/=(modulo_int rhs) { *this = *this / rhs; }
  friend modulo_int binpow(modulo_int val, ll p) {
    modulo_int ans = 1;
    for (; p > 0; p >>= 1) {
      if (p & 1) ans = ans * val;
      val *= val;
    }
    return ans;
  }
  friend ostream& operator<<(ostream& o, modulo_int& a) {
    o << a.val;
    return o;
  }
  friend istream& operator>>(istream& o, modulo_int& a) {
    o >> a.val;
    return o;
  }
};
void solve() {
  int n, k;
  cin >> n >> k;
  vector<modulo_int> DP(k + 1);
  DP[0] = 1;
  modulo_int two = 2;
  modulo_int ways = binpow(two, n - 1);
  for (int i = 1; i <= k; i++) {
    if (n & 1)
      DP[i] = DP[i - 1] * (ways + 1);
    else
      DP[i] = DP[i - 1] * (ways - 1) + binpow(binpow(two, i - 1), n);
  }
  cout << DP[k] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int tc = 1; tc <= t; tc++) {
    solve();
  }
  return MONKE;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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;
using ll = long long;
const int MONKE = 0;
ll inv_mod(ll a, ll m) {
  ll _m = m, q, t, x, y;
  if (m == 1) return 0;
  for (y = 0, x = 1; a > 1; t = y, y = x - q * y, x = t) {
    q = a / m, t = m;
    m = a % m, a = t;
  }
  return x < 0 ? x + _m : x;
}
class modulo_int {
 public:
  ll val;
  static const ll mod = 1e9 + 7;
  modulo_int(ll _val = 0) { val = _val > 0 ? _val % mod : _val % mod + mod; }
  modulo_int operator+(modulo_int rhs) { return modulo_int((val + rhs.val)); }
  modulo_int operator-(modulo_int rhs) { return modulo_int((val - rhs.val)); }
  modulo_int operator*(modulo_int rhs) { return modulo_int((val * rhs.val)); }
  modulo_int operator/(modulo_int rhs) {
    return modulo_int(binpow(rhs, mod - 2) * val);
  }
  void operator+=(modulo_int rhs) { *this = *this + rhs; }
  void operator-=(modulo_int rhs) { *this = *this - rhs; }
  void operator*=(modulo_int rhs) { *this = *this * rhs; }
  void operator/=(modulo_int rhs) { *this = *this / rhs; }
  friend modulo_int binpow(modulo_int val, ll p) {
    modulo_int ans = 1;
    for (; p > 0; p >>= 1) {
      if (p & 1) ans = ans * val;
      val *= val;
    }
    return ans;
  }
  friend ostream& operator<<(ostream& o, modulo_int& a) {
    o << a.val;
    return o;
  }
  friend istream& operator>>(istream& o, modulo_int& a) {
    o >> a.val;
    return o;
  }
};
void solve() {
  int n, k;
  cin >> n >> k;
  vector<modulo_int> DP(k + 1);
  DP[0] = 1;
  modulo_int two = 2;
  modulo_int ways = binpow(two, n - 1);
  for (int i = 1; i <= k; i++) {
    if (n & 1)
      DP[i] = DP[i - 1] * (ways + 1);
    else
      DP[i] = DP[i - 1] * (ways - 1) + binpow(binpow(two, i - 1), n);
  }
  cout << DP[k] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int tc = 1; tc <= t; tc++) {
    solve();
  }
  return MONKE;
}

```