#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4000, Mod = 7340033;
int Add(int x, int y) {
  x += y;
  return x >= Mod ? x - Mod : x;
}
int Sub(int x, int y) {
  x -= y;
  return x < 0 ? x + Mod : x;
}
int Mul(int x, int y) { return 1ll * x * y % Mod; }
int Quick_pow(int x, int po) {
  int Ans = 1;
  for (; po; po >>= 1, x = Mul(x, x))
    if (po & 1) Ans = Mul(Ans, x);
  return Ans;
}
int Inv(int x) { return Quick_pow(x, Mod - 2); }
const int G = 3, IG = 2446678;
int lim, ilim, rev[MAXN + 5];
void ntt(vector<int> &f, int ty) {
  for (int i = 0; i < lim; i++)
    if (i < rev[i]) swap(f[i], f[rev[i]]);
  for (int len = 2; len <= lim; len <<= 1) {
    int w = Quick_pow(ty == 1 ? G : IG, (Mod - 1) / len);
    for (int l = 0; l < lim; l += len) {
      for (int i = l, wk = 1; i < l + len / 2; i++, wk = Mul(wk, w)) {
        int t = Mul(wk, f[i + len / 2]);
        f[i + len / 2] = Sub(f[i], t);
        f[i] = Add(f[i], t);
      }
    }
  }
  if (ty == -1)
    for (int i = 0; i < lim; i++) f[i] = Mul(f[i], ilim);
}
vector<int> operator*(vector<int> f, vector<int> g) {
  int n = ((int)f.size()) + ((int)g.size()) - 1;
  for (lim = 1; lim < n; lim <<= 1)
    ;
  ilim = Inv(lim);
  for (int i = 0; i < lim; i++)
    rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? lim >> 1 : 0);
  f.resize(lim);
  g.resize(lim);
  ntt(f, 1);
  ntt(g, 1);
  for (int i = 0; i < lim; i++) f[i] = Mul(f[i], g[i]);
  ntt(f, -1);
  f.resize(min(n, 1001));
  return f;
}
vector<int> f[35], g[35];
void Dp() {
  f[0].resize(1);
  f[0][0] = 1;
  for (int i = 1; i <= 30; i++) {
    g[i] = f[i - 1] * f[i - 1];
    f[i] = g[i] * g[i];
    int t = f[i].back();
    for (int j = ((int)f[i].size()) - 1; j >= 1; j--) f[i][j] = f[i][j - 1];
    f[i].push_back(t);
  }
}
int t, n, k;
int main() {
  Dp();
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &k);
    int cnt = 0;
    for (int x = n; (x & 1) && x != 1; x = x / 2, cnt++)
      ;
    printf("%d\n", ((int)f[cnt].size()) <= k ? 0 : f[cnt][k]);
  }
  return 0;
}
