#include <bits/stdc++.h>
using namespace std;
const long long MO = 7340033ll;
long long f[33][1010], g[33][1010];
int n, k, q;
int Dfs(int k) {
  if (k == 1) return 0;
  if (!(k % 2)) return 0;
  return Dfs(k / 2) + 1;
}
int main() {
  f[0][0] = 1;
  g[0][0] = 1;
  f[1][0] = 1;
  f[1][1] = 1;
  g[1][0] = 1;
  g[1][1] = 2;
  g[1][2] = 1;
  for (int i = 2; i <= 31; ++i) {
    f[i][0] = g[i][0] = 1;
    for (int j = 1; j <= 1000; ++j)
      for (int k = 0; k < j; ++k)
        f[i][j] = (f[i][j] + g[i - 1][k] * g[i - 1][j - k - 1]) % MO;
    for (int j = 1; j <= 1000; ++j)
      for (int k = 0; k <= j; ++k)
        g[i][j] = (g[i][j] + f[i][k] * f[i][j - k]) % MO;
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d", &n, &k);
    printf("%I64d\n", f[Dfs(n)][k]);
  }
  return 0;
}
