#include <bits/stdc++.h>
using namespace std;
const int MAXK = 1005, MAXM = 30, MOD = 7340033;
int f[MAXM][MAXK];
void DP() {
  static int g[MAXK];
  int m, k, i, j;
  f[0][0] = 1;
  for (m = 1; m < MAXM; m++) {
    memset(g, 0, sizeof(g));
    g[0] = 1;
    for (i = 1; i <= 4; i++)
      for (k = MAXK - 1; k >= 0; k--) {
        for (j = 1; j <= k; j++)
          g[k] = (g[k] + (long long)g[k - j] * f[m - 1][j]) % MOD;
      }
    f[m][0] = 1;
    for (k = 1; k < MAXK; k++) f[m][k] = g[k - 1];
  }
}
int GetM(int n) {
  int res = 0;
  for (; (n & 1) && n > 1; n >>= 1) res++;
  return res;
}
int main() {
  DP();
  int tests, n, m, k;
  scanf("%d", &tests);
  while (tests--) {
    scanf("%d%d", &n, &k);
    m = GetM(n);
    printf("%d\n", f[m][k]);
  }
  return 0;
}
