#include <bits/stdc++.h>
using namespace std;
const long long MOD = 7340033;
long long dp[35][1500];
long long cp[35][1500];
long long compute(long long n, long long k, long long idx) {
  if (k == 0) return 1;
  if (idx == 0) return 0;
  if (dp[idx][k] != -1) return dp[idx][k];
  dp[idx][k] = 0;
  for (int i = 0; i < k; i++) {
    if (cp[idx][i] != -1) continue;
    cp[idx][i] = 0;
    for (int j = 0; j <= i; j++) {
      cp[idx][i] += (compute(n, j, idx - 1) * compute(n, i - j, idx - 1));
      cp[idx][i] %= MOD;
    }
  }
  for (int i = 0; i < k; i++) {
    dp[idx][k] += (cp[idx][i] * cp[idx][k - i - 1]);
    dp[idx][k] %= MOD;
  }
  return dp[idx][k];
}
int main() {
  int tc;
  scanf("%d", &tc);
  memset(cp, -1, sizeof(cp));
  memset(dp, -1, sizeof(dp));
  while (tc--) {
    long long n, k;
    scanf("%lld %lld", &n, &k);
    int step = 0;
    while (n % 2 == 1 && n != 1) {
      step++;
      n /= 2;
    }
    printf("%lld\n", compute(n, k, step));
  }
}
