#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const long long int mod = 1e9 + 7;
long long int powmod(long long int x, long long int y) {
  long long int t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long int gcd(long long int x, long long int y) {
  return y ? gcd(y, x % y) : x;
}
long long int lcm(long long int x, long long int y) {
  return x * (y / gcd(x, y));
}
long long int modd(long long int a) { return (a % mod + mod) % mod; }
double findMod(double a, double b) {
  double mods;
  if (a < 0)
    mods = -a;
  else
    mods = a;
  if (b < 0) b = -b;
  while (mods >= b) mods = mods - b;
  if (a < 0) return -mods;
  return mods;
}
vector<long long int> sieve(int n) {
  int* arr = new int[n + 1]();
  vector<long long int> vect;
  for (long long int i = 2; i <= n; i++)
    if (arr[i] == 0) {
      vect.push_back(i);
      for (long long int j = 2 * i; j <= n; j += i) arr[j] = 1;
    }
  return vect;
}
long long int add(long long int a, long long int b) {
  return modd(modd(a) + modd(b));
}
long long int mul(long long int a, long long int b) {
  return modd(modd(a) * modd(b));
}
int smask(int i, int pos) { return (i | (1 << pos)); }
int clmask(int i, int pos) { return (i & (~(1 << pos))); }
bool chmask(int i, int pos) { return (i & (1 << pos)) != 0; }
double cordist(pair<double, double> a, pair<double, double> b) {
  return sqrt(((a.first - b.first) * (a.first - b.first)) +
              ((a.second - b.second) * (a.second - b.second)));
}
long long binpow(long long a, long long b) {
  if (b <= 0) return 1;
  long long res = binpow(a, b / 2);
  if (b % 2)
    return mul(mul(res, res), a);
  else
    return mul(res, res);
}
long long int divs(long long int a, long long int b) {
  return a * binpow(b, mod - 2);
}
long long int n, m, q, r, i, j;
vector<long long int> arr;
void solve() {
  cin >> n >> q;
  if (n & 1) {
    cout << binpow(binpow(2, n - 1) + 1, q) % mod << '\n';
  } else {
    long long int sparse = binpow(binpow(2, n - 1) - 1, q);
    long long int ans = (binpow(2, (long long int)n * q) - sparse);
    ans *= binpow((binpow(2, n - 1) + 1), mod - 2);
    ans += sparse;
    ans %= mod;
    while (ans < 0) ans += mod;
    cout << ans << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k = 1;
  cin >> k;
  q = 0;
  while (k--) {
    q++;
    solve();
  }
  return 0;
}

### Prompt

Please create a solution in cpp 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;
#pragma GCC optimize("O3")
const long long int mod = 1e9 + 7;
long long int powmod(long long int x, long long int y) {
  long long int t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long int gcd(long long int x, long long int y) {
  return y ? gcd(y, x % y) : x;
}
long long int lcm(long long int x, long long int y) {
  return x * (y / gcd(x, y));
}
long long int modd(long long int a) { return (a % mod + mod) % mod; }
double findMod(double a, double b) {
  double mods;
  if (a < 0)
    mods = -a;
  else
    mods = a;
  if (b < 0) b = -b;
  while (mods >= b) mods = mods - b;
  if (a < 0) return -mods;
  return mods;
}
vector<long long int> sieve(int n) {
  int* arr = new int[n + 1]();
  vector<long long int> vect;
  for (long long int i = 2; i <= n; i++)
    if (arr[i] == 0) {
      vect.push_back(i);
      for (long long int j = 2 * i; j <= n; j += i) arr[j] = 1;
    }
  return vect;
}
long long int add(long long int a, long long int b) {
  return modd(modd(a) + modd(b));
}
long long int mul(long long int a, long long int b) {
  return modd(modd(a) * modd(b));
}
int smask(int i, int pos) { return (i | (1 << pos)); }
int clmask(int i, int pos) { return (i & (~(1 << pos))); }
bool chmask(int i, int pos) { return (i & (1 << pos)) != 0; }
double cordist(pair<double, double> a, pair<double, double> b) {
  return sqrt(((a.first - b.first) * (a.first - b.first)) +
              ((a.second - b.second) * (a.second - b.second)));
}
long long binpow(long long a, long long b) {
  if (b <= 0) return 1;
  long long res = binpow(a, b / 2);
  if (b % 2)
    return mul(mul(res, res), a);
  else
    return mul(res, res);
}
long long int divs(long long int a, long long int b) {
  return a * binpow(b, mod - 2);
}
long long int n, m, q, r, i, j;
vector<long long int> arr;
void solve() {
  cin >> n >> q;
  if (n & 1) {
    cout << binpow(binpow(2, n - 1) + 1, q) % mod << '\n';
  } else {
    long long int sparse = binpow(binpow(2, n - 1) - 1, q);
    long long int ans = (binpow(2, (long long int)n * q) - sparse);
    ans *= binpow((binpow(2, n - 1) + 1), mod - 2);
    ans += sparse;
    ans %= mod;
    while (ans < 0) ans += mod;
    cout << ans << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k = 1;
  cin >> k;
  q = 0;
  while (k--) {
    q++;
    solve();
  }
  return 0;
}

```