#include <bits/stdc++.h>
using namespace std;
const int MAXN = 32, MAXK = 1005, MOD = 7340033;
long long dp[MAXN][MAXK], upd[MAXK];
int main() {
  dp[0][0] = 1;
  for (int i = 1; i < MAXN; i++) {
    fill_n(upd, MAXK, 0);
    for (int j = 0; j < MAXK; j++)
      for (int k = 0; k + j < MAXK; k++)
        upd[j + k] += dp[i - 1][j] * dp[i - 1][k], upd[j + k] %= MOD;
    dp[i][0] = 1;
    for (int j = 1; j < MAXK; j++)
      for (int k = 0; k <= j - 1; k++)
        dp[i][j] += upd[k] * upd[j - 1 - k], dp[i][j] %= MOD;
  }
  int q;
  cin >> q;
  while (q--) {
    int n, k, c = 0;
    cin >> n >> k;
    while (n % 2 == 1 && n != 1) c++, n /= 2;
    if (k == 0)
      cout << 1;
    else
      cout << dp[c][k];
    cout << '\n';
  }
}
