#include <bits/stdc++.h>
using namespace std;
void fft(vector<complex<double> > &a, bool inv) {
  int n = a.size(), j = 0;
  vector<complex<double> > roots(n / 2);
  for (int i = 1; i < n; i++) {
    int bit = (n >> 1);
    while (j >= bit) {
      j -= bit;
      bit >>= 1;
    }
    j += bit;
    if (i < j) swap(a[i], a[j]);
  }
  double ang = 2 * acos(-1) / n * (inv ? -1 : 1);
  for (int i = 0; i < n / 2; i++) {
    roots[i] = complex<double>(cos(ang * i), sin(ang * i));
  }
  for (int i = 2; i <= n; i <<= 1) {
    int step = n / i;
    for (int j = 0; j < n; j += i) {
      for (int k = 0; k < i / 2; k++) {
        complex<double> u = a[j + k], v = a[j + k + i / 2] * roots[step * k];
        a[j + k] = u + v;
        a[j + k + i / 2] = u - v;
      }
    }
  }
  if (inv)
    for (int i = 0; i < n; i++) a[i] /= n;
}
vector<long long int> multiply(vector<long long int> &v,
                               vector<long long int> &w) {
  vector<complex<double> > fv(v.begin(), v.end()), fw(w.begin(), w.end());
  int n = 2;
  while (n < v.size() + w.size()) n <<= 1;
  fv.resize(n);
  fw.resize(n);
  fft(fv, 0);
  fft(fw, 0);
  for (int i = 0; i < n; i++) fv[i] *= fw[i];
  fft(fv, 1);
  n = v.size() + w.size() - 1;
  vector<long long int> ret(n);
  for (int i = 0; i < n; i++) ret[i] = (long long int)round(fv[i].real());
  return ret;
}
vector<long long int> multiply(vector<long long int> &v,
                               vector<long long int> &w, long long int mod) {
  int n = 2;
  while (n < v.size() + w.size()) n <<= 1;
  vector<complex<double> > v1(n), v2(n), r1(n), r2(n);
  for (int i = 0; i < v.size(); i++) {
    v1[i] = complex<double>(v[i] >> 15, v[i] & 32767);
  }
  for (int i = 0; i < w.size(); i++) {
    v2[i] = complex<double>(w[i] >> 15, w[i] & 32767);
  }
  fft(v1, 0);
  fft(v2, 0);
  for (int i = 0; i < n; i++) {
    int j = (i ? (n - i) : i);
    complex<double> ans1 = (v1[i] + conj(v1[j])) * complex<double>(0.5, 0);
    complex<double> ans2 = (v1[i] - conj(v1[j])) * complex<double>(0, -0.5);
    complex<double> ans3 = (v2[i] + conj(v2[j])) * complex<double>(0.5, 0);
    complex<double> ans4 = (v2[i] - conj(v2[j])) * complex<double>(0, -0.5);
    r1[i] = (ans1 * ans3) + (ans1 * ans4) * complex<double>(0, 1);
    r2[i] = (ans2 * ans3) + (ans2 * ans4) * complex<double>(0, 1);
  }
  fft(r1, 1);
  fft(r2, 1);
  n = v.size() + w.size() - 1;
  n = min(n, 1001);
  vector<long long int> ret(n);
  for (int i = 0; i < n; i++) {
    long long int av = (long long int)round(r1[i].real());
    long long int bv =
        (long long int)round(r1[i].imag()) + (long long int)round(r2[i].real());
    long long int cv = (long long int)round(r2[i].imag());
    av %= mod, bv %= mod, cv %= mod;
    ret[i] = (av << 30) + (bv << 15) + cv;
    ret[i] %= mod;
    ret[i] += mod;
    ret[i] %= mod;
  }
  return ret;
}
const long long int K = 7340033;
vector<long long int> A[105], B, C;
int calc(int n) {
  if (n % 2 == 0 || n == 1) return 0;
  return calc((n - 1) / 2) + 1;
}
int dd[104];
void solve(int t) {
  int st = 0;
  for (int i = 0; i <= t; i++) {
    if (dd[i]) st = i;
  }
  for (int i = st + 1; i <= t; i++) {
    A[i] = multiply(A[i - 1], A[i - 1], K);
    A[i] = multiply(A[i], A[i], K);
    A[i].insert(A[i].begin(), 1);
    dd[i] = 1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  A[0].push_back(1);
  int q;
  cin >> q;
  for (int z = 1; z <= q; z++) {
    int n, k;
    cin >> n >> k;
    int t = calc(n);
    if (!dd[t]) solve(t);
    if (k < A[t].size())
      cout << A[t][k] << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
