#include <bits/stdc++.h>
using namespace std;
const int maxk = 1000;
const int mod = 7340033;
int T, n, m, f[31][maxk + 5];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int tmp[maxk + 5];
int main() {
  f[0][0] = 1;
  for (int i = 1; i <= 30; i++) {
    f[i][0] = 1;
    for (int op = 1; op <= 4; op++) {
      memset(tmp, 0, sizeof(tmp));
      for (int j = 0; j <= maxk; j++)
        for (int k = 0; k <= j; k++)
          tmp[j] = (tmp[j] + 1ll * f[i][k] * f[i - 1][j - k] % mod) % mod;
      for (int j = 0; j <= maxk; j++) f[i][j] = tmp[j];
    }
    for (int j = maxk; j; j--) f[i][j] = f[i][j - 1];
  }
  T = read();
  while (T--) {
    n = read(), m = read();
    int cnt = 0;
    while ((n & 1) && n > 1) cnt++, n >>= 1;
    printf("%d\n", f[cnt][m]);
  }
  return 0;
}
