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 INF = (int)1E9;
const long long INFLL = (long long)1E15;
const long long MOD = (long long)7340033;
const double PI = acos(-1);
const double EPS = 1E-9;
bool between(int x, int l, int r) { return (l <= x && x <= r); }
long long prr;
long long kali(long long x, long long y) {
  return ((x % MOD) * (y % MOD)) % MOD;
}
long long expmod(long long x, long long y) {
  if (y == 0) return 1ll;
  if (y == 1) return x % MOD;
  long long temp = expmod(x, y / 2);
  temp = kali(temp, temp);
  if (y & 1) return kali(temp, x);
  return temp;
}
inline void findr() {
  for (prr = 1;; prr++) {
    cout << prr << endl;
    set<long long> S;
    S.clear();
    long long cur = prr;
    bool cek = true;
    for (int i = 1; i < MOD; i += 1) {
      if (S.count(cur)) {
        cek = false;
        break;
      }
      S.insert(cur);
      cur = kali(cur, prr);
    }
    if (cek) {
      return;
    }
  }
}
void FFT(vector<long long>& a, int sign = 1) {
  int n = a.size();
  long long theta = expmod(prr, (MOD - 1) / n);
  if (sign == -1) theta = expmod(theta, MOD - 2);
  for (int i = 0, j = 1; j < n - 1; ++j) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1)
      ;
    if (j < i) swap(a[i], a[j]);
  }
  for (int m, mh = 1; (m = mh << 1) <= n; mh = m) {
    long long irev = 0;
    for (int i = 0; i < n; i += m) {
      long long w = expmod(theta, irev);
      for (int k = n >> 2; k > (irev ^= k); k >>= 1)
        ;
      for (int j = i; j < mh + i; ++j) {
        int k = j + mh;
        long long x = a[j] - a[k];
        x += MOD;
        x %= MOD;
        a[j] += a[k];
        a[j] %= MOD;
        a[k] = kali(w, x);
      }
    }
  }
  if (sign == -1)
    for (int i = 0; i < n; i += 1) a[i] = kali(a[i], expmod(n, MOD - 2));
}
void pkali(vector<long long>& res, vector<long long>& a, vector<long long>& b) {
  res.clear();
  int n = a.size() + b.size() - 1;
  for (int i = 1; i < n; i <<= 1)
    if (n & i) n += i;
  a.resize(n);
  b.resize(n);
  FFT(a);
  FFT(b);
  for (int i = 0; i < n; i += 1) res.push_back(kali(a[i], b[i]));
  FFT(res, -1);
}
string tostring(int x) {
  char dum[20];
  sprintf(dum, "%d", x);
  string ret(dum);
  return ret;
}
long long ans[40][1010];
inline void prework() {
  vector<long long> cur;
  cur.push_back(1);
  for (int i = 0; i < 1000; i += 1) cur.push_back(0);
  ans[0][0] = 1;
  for (int i = 1; i < 1001; i += 1) ans[0][i] = 0;
  for (int i = 1; i < 40; i += 1) {
    vector<long long> a, b;
    a.clear();
    b.clear();
    for (int j = 0; j < 1001; j += 1) a.push_back(cur[j]), b.push_back(cur[j]);
    vector<long long> c;
    c.clear();
    pkali(c, a, b);
    a.clear();
    b.clear();
    for (int j = 0; j < 1001; j += 1) a.push_back(c[j]), b.push_back(c[j]);
    cur.clear();
    pkali(cur, a, b);
    a.clear();
    b.clear();
    for (int j = 0; j < 1000; j += 1) ans[i][j + 1] = cur[j];
    ans[i][0] = 1;
    c.clear();
    for (int j = 0; j < 1001; j += 1) c.push_back(ans[i][j]);
    cur = c;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  prr = 3;
  prework();
  int kasus;
  cin >> kasus;
  while (kasus--) {
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    while (n != 1) {
      if ((n - 1) % 2 == 0) {
        cnt++;
        n--;
        n /= 2;
      } else
        break;
    }
    cout << ans[cnt][m] << endl;
  }
  return 0;
}