#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
template <class T>
void show(const vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << endl;
}
const int N = 1002;
const long long M = 7340033;
const long long root = 5;
const long long root_pw = 20;
inline long long MOD(long long a, long long mod) {
  if (a >= 0) return a >= mod ? a % mod : a;
  if (a <= -mod) a %= mod;
  return a ? mod + a : a;
}
long long pw(long long a, long long p, long long mod) {
  if (!p) return 1;
  long long ret = pw(a, p >> 1, mod);
  ret = MOD(ret * ret, mod);
  if (p & 1) ret = MOD(ret * a, mod);
  return ret;
}
const long long inv_root = pw(root, M - 2, M);
void fft(vector<long long> &a, int lgn, bool invert) {
  int n = ((int)(a.size()));
  int rev = 0;
  for (int i = 0; i < n; ++i) {
    if (rev < i) swap(a[i], a[rev]);
    for (int j = lgn - 1; j >= 0; --j) {
      rev ^= (1 << j);
      if ((rev >> j) & 1) break;
    }
  }
  for (int len = 2, pw = 1; len <= n; len <<= 1, ++pw) {
    long long wlen = invert ? inv_root : root;
    for (int j = pw; j < root_pw; ++j) wlen = MOD(wlen * wlen, M);
    for (int st = 0; st < n; st += len) {
      long long w = 1;
      for (int i = 0; i < (len >> 1); ++i, w = MOD(w * wlen, M)) {
        long long u = a[i + st], v = MOD(a[i + st + (len >> 1)] * w, M);
        a[i + st] = MOD(u + v, M);
        a[i + st + (len >> 1)] = MOD(u - v, M);
      }
    }
  }
  if (invert)
    for (int i = 0; i < int(n); ++i) a[i] = MOD(a[i] * pw(n, M - 2, M), M);
}
inline int lg2(int n) {
  for (int i = 0;; ++i)
    if ((1 << i) >= n) return i;
  return -1;
}
inline vector<long long> multiply(const vector<long long> &a,
                                  const vector<long long> &b) {
  vector<long long> fa = a, fb = b;
  int lgn = lg2(max(((int)(a.size())), ((int)(b.size())))) + 1;
  int n = 1 << lgn;
  while (((int)(fa.size())) < n) fa.push_back(0);
  while (((int)(fb.size())) < n) fb.push_back(0);
  fft(fa, lgn, 0);
  fft(fb, lgn, 0);
  for (int i = 0; i < int(n); ++i) fa[i] = MOD(fa[i] * fb[i], M);
  fft(fa, lgn, 1);
  return fa;
}
vector<long long> dp[100];
vector<long long> get_lazy(int cnt) {
  if (((int)(dp[cnt].size()))) return dp[cnt];
  dp[cnt].resize(N);
  dp[cnt][0] = 1;
  if (!cnt) return dp[cnt];
  vector<long long> a = get_lazy(cnt - 1);
  vector<long long> b = multiply(a, a);
  b.resize(N);
  b = multiply(b, a);
  b.resize(N);
  b = multiply(b, a);
  b.resize(N);
  for (int i = 1; i < N; ++i) {
    a[i] = b[i - 1];
  }
  a[0] = 1;
  return dp[cnt] = a;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  for (int iter = 0; iter < int(q); ++iter) {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while (n & 1) {
      n >>= 1;
      if (!n) break;
      ++cnt;
    }
    vector<long long> a = get_lazy(cnt);
    cout << a[k] << "\n";
  }
}
