#include <bits/stdc++.h>
const int N = 10050, mo = 7340033, G = 3;
using namespace std;
inline int gi() {
  char ch = getchar();
  int x = 0, q = 0;
  while (ch < '0' || ch > '9') ch == '-' ? q = 1 : 0, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return q ? (-x) : x;
}
int dp[40][1050], n, l, rev[N], a[N], w[N], ny;
int fap(int a, int b) {
  int s = 1;
  while (b) {
    if (b & 1) s = 1ll * s * a % mo;
    b >>= 1, a = 1ll * a * a % mo;
  }
  return s;
}
void fft(int *f, int p) {
  for (int i = 1; i < n; ++i)
    if (i < rev[i]) swap(f[i], f[rev[i]]);
  int g, gn, x, y;
  for (int i = 1; i < n; i <<= 1) {
    gn = w[i];
    for (int j = 0; j < n; j += i << 1) {
      g = 1;
      for (int k = 0; k < i; ++k, g = 1ll * g * gn % mo) {
        x = f[j + k], y = 1ll * f[j + k + i] * g % mo;
        f[j + k] = (x + y) % mo, f[j + k + i] = (x - y + mo) % mo;
      }
    }
  }
  if (p == 1) return;
  reverse(f + 1, f + n);
  for (int i = 0; i < n; ++i) f[i] = 1ll * f[i] * ny % mo;
  return;
}
int main() {
  dp[0][0] = 1;
  for (n = 1; n <= 4000; n <<= 1) ++l;
  for (int i = 1; i < n; i <<= 1) w[i] = fap(G, (mo - 1) / (i << 1));
  for (int i = 1; i < n; ++i)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (l - 1));
  ny = fap(n, mo - 2);
  for (int i = 1; i <= 31; ++i) {
    for (int j = 0; j <= 1000; ++j) a[j] = dp[i - 1][j];
    for (int j = 1001; j < n; ++j) a[j] = 0;
    fft(a, 1);
    for (int j = 0; j < n; ++j)
      a[j] = 1ll * a[j] * a[j] % mo * a[j] % mo * a[j] % mo;
    fft(a, -1);
    for (int j = 1000; j; --j) dp[i][j] = a[j - 1];
    dp[i][0] = 1;
  }
  int q = gi();
  while (q--) {
    int a = gi(), b = gi(), c = 0;
    while (a) {
      if (a & 1) {
        if (a > 1)
          ++c;
        else
          break;
        a >>= 1;
      } else
        break;
    }
    printf("%d\n", dp[c][b]);
  }
  return 0;
}
