#include <bits/stdc++.h>
using namespace std;
const int mod = 7340033;
int dp[40][1009], f[40][1009];
void init() {
  dp[0][0] = 1;
  for (int i = 1; i <= 30; i++) {
    f[i][0] = dp[i][0] = 1;
    for (int j = 1; j <= 1000; j++)
      for (int k = 0; k <= j; k++)
        f[i][j] = (f[i][j] + (long long)dp[i - 1][k] * dp[i - 1][j - k]) % mod;
    for (int j = 1; j <= 1000; j++)
      for (int k = 0; k <= j - 1; k++)
        dp[i][j] = (dp[i][j] + (long long)f[i][k] * f[i][j - k - 1]) % mod;
  }
}
int main() {
  init();
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    int n, k, h = 0;
    scanf("%d%d", &n, &k);
    while (n > 1 && (n & 1)) h++, n >>= 1;
    printf("%d\n", dp[h][k]);
  }
  return 0;
}
