#include <bits/stdc++.h>
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
using namespace std;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const long long int INF = 1e18;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  long long int n, k, i;
  cin >> n >> k;
  long long int ans00[k + 1];
  long long int ans01[k + 1];
  long long int ans10[k + 1];
  long long int ans11[k + 1];
  long long int ans[k + 1];
  long long int answ[k + 1];
  answ[0] = 1;
  ans[0] = 1;
  long long int fo = (power(2, n - 1) - 1) % 1000000007;
  long long int fe = (power(2, n - 1)) % 1000000007;
  for (i = 1; i <= k; i++) {
    answ[i] = (answ[i - 1] * (2 * fe)) % 1000000007;
    if (n % 2) {
      ans11[i] = ans[i - 1];
    } else
      ans11[i] = 0;
    if ((n % 2) == 0) {
      ans10[i] = answ[i - 1];
    } else
      ans10[i] = 0;
    if (n % 2) {
      ans00[i] = (((ans[i - 1]) * (fo + 1)) % 1000000007);
    } else {
      ans00[i] = (((ans[i - 1]) * (fe - 1)) % 1000000007);
    }
    ans[i] = ans00[i] + ans10[i] + ans11[i];
    ans[i] = (ans[i] % 1000000007);
  }
  cout << ans[k] << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC = 1, te = 0;
  cin >> TC;
  while (te++ < TC) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}

### 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>
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
using namespace std;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const long long int INF = 1e18;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  long long int n, k, i;
  cin >> n >> k;
  long long int ans00[k + 1];
  long long int ans01[k + 1];
  long long int ans10[k + 1];
  long long int ans11[k + 1];
  long long int ans[k + 1];
  long long int answ[k + 1];
  answ[0] = 1;
  ans[0] = 1;
  long long int fo = (power(2, n - 1) - 1) % 1000000007;
  long long int fe = (power(2, n - 1)) % 1000000007;
  for (i = 1; i <= k; i++) {
    answ[i] = (answ[i - 1] * (2 * fe)) % 1000000007;
    if (n % 2) {
      ans11[i] = ans[i - 1];
    } else
      ans11[i] = 0;
    if ((n % 2) == 0) {
      ans10[i] = answ[i - 1];
    } else
      ans10[i] = 0;
    if (n % 2) {
      ans00[i] = (((ans[i - 1]) * (fo + 1)) % 1000000007);
    } else {
      ans00[i] = (((ans[i - 1]) * (fe - 1)) % 1000000007);
    }
    ans[i] = ans00[i] + ans10[i] + ans11[i];
    ans[i] = (ans[i] % 1000000007);
  }
  cout << ans[k] << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC = 1, te = 0;
  cin >> TC;
  while (te++ < TC) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}

```