#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(((long double)-1.0));
void fft(vector<complex<long double> > &a, bool invert) {
  int n = (int)a.size();
  for (int i = 1, j = 0; i < n; ++i) {
    int bit = n >> 1;
    for (; j >= bit; bit >>= 1) j -= bit;
    j += bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    long double ang = 2 * PI / len * (invert ? -1 : 1);
    complex<long double> wlen(cos(ang), sin(ang));
    for (int i = 0; i < n; i += len) {
      complex<long double> w(1);
      for (int j = 0; j < len / 2; ++j) {
        complex<long double> u = a[i + j], v = a[i + j + len / 2] * w;
        a[i + j] = u + v;
        a[i + j + len / 2] = u - v;
        w *= wlen;
      }
    }
  }
  if (invert)
    for (int i = 0; i < n; ++i) a[i] /= n;
}
void multiply(const vector<long long> &a, const vector<long long> &b,
              vector<long long> &res) {
  vector<complex<long double> > fa(a.begin(), a.end()), fb(b.begin(), b.end());
  size_t n = 1;
  while (n < max(a.size(), b.size())) n <<= 1;
  n <<= 1;
  fa.resize(n), fb.resize(n);
  fft(fa, false), fft(fb, false);
  for (size_t i = 0; i < n; ++i) fa[i] *= fb[i];
  fft(fa, true);
  res.resize(n);
  for (size_t i = 0; i < n; ++i) res[i] = (long long)(fa[i].real() + 0.5);
}
vector<long long> dp[31];
void calc(int n) {
  dp[n].resize(1010, 0);
  dp[n][0] = 1;
  if (!n) return;
  calc(n - 1);
  vector<long long> temp, temp1;
  multiply(dp[n - 1], dp[n - 1], temp);
  temp.resize(1010);
  for (int i = 1; i < 1010; ++i) {
    temp[i] %= 7340033;
    if (temp[i] < 0) temp[i] += 7340033;
  }
  multiply(temp, temp, temp1);
  for (int i = 1; i <= 1000; ++i) dp[n][i] = temp1[i - 1];
  for (int i = 1; i <= 1000; ++i) {
    dp[n][i] %= 7340033;
    if (dp[n][i] < 0) dp[n][i] += 7340033;
  }
}
int main() {
  int q, n, k;
  calc(30);
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &n);
    scanf("%d", &k);
    int n1 = n;
    int c = 0;
    while (true) {
      if (n1 % 2 == 0) break;
      if (n1 == 1) break;
      n1 /= 2;
      c++;
    }
    printf("%lld\n", dp[c][k]);
  }
}
