#include <bits/stdc++.h>
using namespace std;
const int maxn = 400010;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
const double Pi = acos(-1.0);
int n, m, k, t;
long long fact[maxn], invFact[maxn];
int dir[][2] = {{0, 0},  {0, 1},   {-1, 0}, {0, -1}, {1, 0},
                {-1, 1}, {-1, -1}, {1, -1}, {1, 1}};
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
inline int gcd(int x, int y) {
  if (!x) return y;
  return gcd(y % x, x);
}
inline long long power(long long x, long long k, long long p) {
  long long res = 1;
  for (; k; k >>= 1, x = (long long)x * x % p)
    if (k & 1) res = (long long)res * x % p;
  return res;
}
long long A(int n, int k) {
  if (k > n) {
    return 0;
  }
  return fact[n] * invFact[k] % mod * invFact[n - k] % mod;
}
void solve() {
  n = read();
  k = read();
  fact[0] = invFact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = (fact[i - 1]) * i % mod;
    invFact[i] = power(fact[i], mod - 2, mod);
  }
  long long ji = 0, ou = 0;
  for (int i = 0; i <= n; ++i) {
    if (i % 2) {
    } else {
      ou = (ou + A(n, i)) % mod;
    }
  }
  long long nn = power(2, n, mod);
  long long ans = 0;
  if (n % 2 == 1)
    ans++;
  else
    ou--;
  ans = (ans + ou) % mod;
  long long now = power(ans, k, mod);
  if (n % 2 == 0) {
    for (int i = k; i >= 1; --i) {
      now += power(nn, i - 1, mod) * power(ans, k - i, mod);
      now %= mod;
    }
  }
  printf("%lld\n", now);
  return;
}
int main() {
  t = read();
  while (t--) {
    solve();
  }
  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>
using namespace std;
const int maxn = 400010;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
const double Pi = acos(-1.0);
int n, m, k, t;
long long fact[maxn], invFact[maxn];
int dir[][2] = {{0, 0},  {0, 1},   {-1, 0}, {0, -1}, {1, 0},
                {-1, 1}, {-1, -1}, {1, -1}, {1, 1}};
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
inline int gcd(int x, int y) {
  if (!x) return y;
  return gcd(y % x, x);
}
inline long long power(long long x, long long k, long long p) {
  long long res = 1;
  for (; k; k >>= 1, x = (long long)x * x % p)
    if (k & 1) res = (long long)res * x % p;
  return res;
}
long long A(int n, int k) {
  if (k > n) {
    return 0;
  }
  return fact[n] * invFact[k] % mod * invFact[n - k] % mod;
}
void solve() {
  n = read();
  k = read();
  fact[0] = invFact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = (fact[i - 1]) * i % mod;
    invFact[i] = power(fact[i], mod - 2, mod);
  }
  long long ji = 0, ou = 0;
  for (int i = 0; i <= n; ++i) {
    if (i % 2) {
    } else {
      ou = (ou + A(n, i)) % mod;
    }
  }
  long long nn = power(2, n, mod);
  long long ans = 0;
  if (n % 2 == 1)
    ans++;
  else
    ou--;
  ans = (ans + ou) % mod;
  long long now = power(ans, k, mod);
  if (n % 2 == 0) {
    for (int i = k; i >= 1; --i) {
      now += power(nn, i - 1, mod) * power(ans, k - i, mod);
      now %= mod;
    }
  }
  printf("%lld\n", now);
  return;
}
int main() {
  t = read();
  while (t--) {
    solve();
  }
  return 0;
}

```