#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long mod) {
  long long aInPow = a, ans = 1;
  while (b != 0) {
    if (b % 2) ans = (ans * aInPow) % mod;
    aInPow = (aInPow * aInPow) % mod;
    b >>= 1;
  }
  return ans;
}
void qs(vector<long long>& a, vector<long long>& b, long long l, long long r) {
  if (r - l <= 1) return;
  long long mid = a[l + rand() % (r - l - 1)], x = l, y = l;
  for (long long i = l; i < r; i++) {
    if (a[i] < mid) {
      swap(a[i], a[x]);
      swap(b[i], b[x]);
      if (x != y) {
        swap(a[i], a[y]);
        swap(b[i], b[y]);
      }
      x++;
      y++;
    } else if (a[i] == mid) {
      swap(a[i], a[y]);
      swap(b[i], b[y]);
      y++;
    }
  }
  qs(a, b, l, x);
  qs(a, b, y, r);
}
long long gcd(long long a, long long b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
long long f(long long n) {
  long long i, ans = n;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      ans -= ans / i;
    }
  }
  if (n > 1) ans -= ans / n;
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long p = 1e9 + 7;
    long long n, k;
    cin >> n >> k;
    long long c2 = power(2, n - 1, p) % p, c = (2 * c2) % p;
    if (n & 1)
      cout << power((c2 + 1) % p, k, p) << "\n";
    else
      cout << ((power(c, k, p) * 2 + c * power(c2 - 1, k, p)) % p *
               power(c + 2, p - 2, p)) %
                  p
           << "\n";
  }
}

### Prompt

Generate a cpp solution to the following problem:

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;
long long power(long long a, long long b, long long mod) {
  long long aInPow = a, ans = 1;
  while (b != 0) {
    if (b % 2) ans = (ans * aInPow) % mod;
    aInPow = (aInPow * aInPow) % mod;
    b >>= 1;
  }
  return ans;
}
void qs(vector<long long>& a, vector<long long>& b, long long l, long long r) {
  if (r - l <= 1) return;
  long long mid = a[l + rand() % (r - l - 1)], x = l, y = l;
  for (long long i = l; i < r; i++) {
    if (a[i] < mid) {
      swap(a[i], a[x]);
      swap(b[i], b[x]);
      if (x != y) {
        swap(a[i], a[y]);
        swap(b[i], b[y]);
      }
      x++;
      y++;
    } else if (a[i] == mid) {
      swap(a[i], a[y]);
      swap(b[i], b[y]);
      y++;
    }
  }
  qs(a, b, l, x);
  qs(a, b, y, r);
}
long long gcd(long long a, long long b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
long long f(long long n) {
  long long i, ans = n;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      ans -= ans / i;
    }
  }
  if (n > 1) ans -= ans / n;
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long p = 1e9 + 7;
    long long n, k;
    cin >> n >> k;
    long long c2 = power(2, n - 1, p) % p, c = (2 * c2) % p;
    if (n & 1)
      cout << power((c2 + 1) % p, k, p) << "\n";
    else
      cout << ((power(c, k, p) * 2 + c * power(c2 - 1, k, p)) % p *
               power(c + 2, p - 2, p)) %
                  p
           << "\n";
  }
}

```