#include <bits/stdc++.h>
long long num[1005];
long long dp[30][1005];
const int mod = 7340033;
void init() {
  num[0] = 1;
  dp[0][0] = 1;
  for (int i = 1; i < 30; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= 1000; j++) {
      for (int k = 0; k < j; k++)
        dp[i][j] = (dp[i][j] + num[k] * num[j - 1 - k] % mod) % mod;
    }
    num[0] = 1;
    for (int j = 1; j <= 1000; j++) num[j] = 0;
    for (int j = 1; j <= 1000; j++) {
      for (int k = 0; k <= j; k++)
        num[j] = (num[j] + dp[i][k] * dp[i][j - k] % mod) % mod;
    }
  }
}
int main() {
  int T, n, k;
  init();
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    int count = 0;
    while (n % 2 == 1 && n > 1) {
      n /= 2;
      count++;
    }
    printf("%lld\n", dp[count][k]);
  }
}
