#include <bits/stdc++.h>
using namespace std;
const int MOD = 7340033;
int T, n, k;
long long f[33][1010];
long long g[1010];
void init() {
  f[0][0] = 1;
  int i, j, a, b;
  for (i = 1; i <= (int)(31); ++i) {
    f[i][0] = 1;
    memset(g, 0, sizeof(g));
    for (a = 0; a <= 1000 && f[i - 1][a]; ++a)
      for (b = 0; b + a <= 1000 && f[i - 1][b]; ++b)
        g[a + b] = (g[a + b] + f[i - 1][a] * f[i - 1][b]) % MOD;
    for (j = 1; j <= 1000; ++j) {
      int t = j - 1;
      for (a = 0; a <= t; ++a) f[i][j] = (f[i][j] + g[a] * g[t - a]) % MOD;
    }
  }
}
int main() {
  init();
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    int cnt(0);
    while (k && (n & 1) && n > 1) {
      n >>= 1;
      ++cnt;
    }
    cout << f[cnt][k] << endl;
  }
  return 0;
}
