#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ln, lk, lm;
long long dp[35][1005], tmp[1005];
int cnt = 0;
void init() {
  dp[0][0] = 1;
  tmp[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] += (tmp[k] * tmp[j - k - 1]) % 7340033;
        dp[i][j] %= 7340033;
      }
    }
    for (int j = 1; j <= 1000; j++) tmp[j] = 0;
    tmp[0] = 1;
    for (int j = 1; j <= 1000; j++) {
      for (int k = 0; k <= j; k++) {
        tmp[j] += (dp[i][k] * dp[i][j - k]) % 7340033;
        tmp[j] %= 7340033;
      }
    }
  }
}
int main() {
  init();
  int q;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &n, &k);
    if (k == 0)
      puts("1");
    else {
      int id = 0;
      while ((n & 1) && n > 1) {
        n >>= 1;
        id++;
      }
      printf("%lld\n", dp[id][k]);
    }
  }
  return 0;
}
