Problem: Vasily the bear has got a large square white table of n rows and n columns. The table has got a black border around this table.

<image> The example of the initial table at n = 5.

Vasily the bear wants to paint his square table in exactly k moves. Each move is sequence of actions:

  1. The bear chooses some square inside his table. At that the square must have a black border painted around it. Also, the square shouldn't contain a black cell. The number of cells in the square shouldn't be less than 2. 
  2. The bear chooses some row and some column inside the chosen square. Then he paints each cell of this row and this column inside the chosen square. After that the rectangles, formed by the square's border and the newly painted cells, must be squares of a non-zero area. 

<image> An example of correct painting at n = 7 и k = 2.

The bear already knows numbers n and k. Help him — find the number of ways to paint the square in exactly k moves. Two ways to paint are called distinct if the resulting tables will differ in at least one cell. As the answer can be rather large, print the remainder after dividing it by 7340033.

Input

The first line contains integer q (1 ≤ q ≤ 105) — the number of test data.

Each of the following q lines contains two integers n and k (1 ≤ n ≤ 109, 0 ≤ k ≤ 1000) — the size of the initial table and the number of moves for the corresponding test.

Output

For each test from the input print the answer to the problem modulo 7340033. Print the answers to the tests in the order in which the tests are given in the input.

Examples

Input

8
1 0
1 1
3 0
3 1
2 0
2 1
3 2
7 2


Output

1
0
1
1
1
0
0
4

Note

All possible painting ways for the test n = 7 and k = 2 are:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1003;
const int prime = 7340033;
const long double PI = acos(((long double)-1.0));
namespace FFT {
const int N = 20;
const int MAX_N = (1 << N);
class cmplx {
 private:
  long double x, y;

 public:
  cmplx() : x(0.0), y(0.0) {}
  cmplx(long double a) : x(a), y(0.0) {}
  cmplx(long double a, long double b) : x(a), y(b) {}
  long double get_real() { return this->x; }
  long double get_img() { return this->y; }
  cmplx conj() { return cmplx(this->x, -(this->y)); }
  cmplx operator=(const cmplx& a) {
    this->x = a.x;
    this->y = a.y;
    return *this;
  }
  cmplx operator+(const cmplx& b) {
    return cmplx(this->x + b.x, this->y + b.y);
  }
  cmplx operator-(const cmplx& b) {
    return cmplx(this->x - b.x, this->y - b.y);
  }
  cmplx operator*(const long double& num) {
    return cmplx(this->x * num, this->y * num);
  }
  cmplx operator/(const long double& num) {
    return cmplx(this->x / num, this->y / num);
  }
  cmplx operator*(const cmplx& b) {
    return cmplx(this->x * b.x - this->y * b.y, this->y * b.x + this->x * b.y);
  }
  cmplx operator/(const cmplx& b) {
    cmplx temp(b.x, -b.y);
    cmplx n = (*this) * temp;
    return n / (b.x * b.x + b.y * b.y);
  }
};
cmplx w[MAX_N];
cmplx f1[MAX_N];
int rev[MAX_N];
void ReserveBits(int k) {
  static int rk = -1, lim;
  if (k == rk) return;
  rk = k, lim = 1 << k;
  for (int i = 1; i <= lim; ++i) {
    int j = rev[i - 1], t = k - 1;
    while (t >= 0 && ((j >> t) & 1)) {
      j ^= 1 << t;
      --t;
    }
    if (t >= 0) {
      j ^= 1 << t;
      --t;
    }
    rev[i] = j;
  }
}
void fft(cmplx* a, int k) {
  ReserveBits(k);
  int n = 1 << k;
  for (int i = 0; i < n; ++i)
    if (rev[i] > i) swap(a[i], a[rev[i]]);
  for (int l = 2, m = 1; l <= n; l += l, m += m) {
    if (w[m].get_real() == 0 && w[m].get_img() == 0) {
      long double angle = PI / m;
      cmplx ww(cos(angle), sin(angle));
      if (m > 1) {
        for (int j = 0; j < m; ++j) {
          if (j & 1)
            w[m + j] = w[(m + j) / 2] * ww;
          else
            w[m + j] = w[(m + j) / 2];
        }
      } else
        w[m] = cmplx(1, 0);
    }
    for (int i = 0; i < n; i += l) {
      for (int j = 0; j < m; ++j) {
        cmplx v = a[i + j], u = a[i + j + m] * w[m + j];
        a[i + j] = v + u;
        a[i + j + m] = v - u;
      }
    }
  }
}
vector<long long> mul(const vector<long long>& a, const vector<long long>& b) {
  int k = 1;
  while ((1 << k) < (a.size() + b.size())) ++k;
  int n = (1 << k);
  for (int i = 0; i < n; ++i) f1[i] = cmplx(0, 0);
  for (int i = 0; i < a.size(); ++i) f1[i] = f1[i] + cmplx(a[i], 0);
  for (int i = 0; i < b.size(); ++i) f1[i] = f1[i] + cmplx(0, b[i]);
  fft(f1, k);
  for (int i = 0; i <= n / 2; ++i) {
    cmplx p = f1[i] + f1[(n - i) % n].conj();
    cmplx _q = f1[(n - i) % n] - f1[i].conj();
    cmplx q(_q.get_img(), _q.get_real());
    f1[i] = (p * q) * 0.25;
    if (i > 0) f1[(n - i)] = f1[i].conj();
  }
  for (int i = 0; i < n; ++i) f1[i] = f1[i].conj();
  fft(f1, k);
  vector<long long> ans(a.size() + b.size() - 1);
  for (int i = 0; i < ans.size(); ++i) {
    if (f1[i].get_real() < 0) {
      ans[i] = (long long)(f1[i].get_real() / n - 0.5);
      ans[i] %= prime;
      if (ans[i] < 0) ans[i] += prime;
    } else {
      ans[i] = (long long)(f1[i].get_real() / n + 0.5);
      ans[i] %= prime;
      if (ans[i] < 0) ans[i] += prime;
    }
  }
  return ans;
}
};  // namespace FFT
vector<long long> ans[32];
vector<long long> temp;
void solve() {
  ans[0].resize(MAXN, 0);
  ans[0][0] = 1;
  for (int i = 1; i < 32; i++) {
    ans[i].resize(MAXN, 0);
    ans[i][0] = 1;
    temp = FFT::mul(ans[i - 1], ans[i - 1]);
    temp = FFT::mul(temp, temp);
    for (int j = 0; j < MAXN - 1; j++) ans[i][j + 1] = temp[j];
  }
}
int main() {
  int t;
  solve();
  cin >> t;
  while (t--) {
    long long n, k, cnt = 0;
    cin >> n >> k;
    while (n > 1 && n & 1) n >>= 1, cnt++;
    cout << ans[cnt][k] << endl;
  }
  return 0;
}