#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
const long long INFLL = (long long)1E15;
const long long MOD = (long long)7340033;
const double PI = acos(-1);
const double EPS = 1E-9;
bool between(int x, int l, int r) { return (l <= x && x <= r); }
long long prr;
long long kali(long long x, long long y) {
  return ((x % MOD) * (y % MOD)) % MOD;
}
long long expmod(long long x, long long y) {
  if (y == 0) return 1ll;
  if (y == 1) return x % MOD;
  long long temp = expmod(x, y / 2);
  temp = kali(temp, temp);
  if (y & 1) return kali(temp, x);
  return temp;
}
inline void findr() {
  for (prr = 1;; prr++) {
    cout << prr << endl;
    set<long long> S;
    S.clear();
    long long cur = prr;
    bool cek = true;
    for (int i = 1; i < MOD; i += 1) {
      if (S.count(cur)) {
        cek = false;
        break;
      }
      S.insert(cur);
      cur = kali(cur, prr);
    }
    if (cek) {
      return;
    }
  }
}
void FFT(vector<long long>& a, int sign = 1) {
  int n = a.size();
  long long theta = expmod(prr, (MOD - 1) / n);
  if (sign == -1) theta = expmod(theta, MOD - 2);
  for (int i = 0, j = 1; j < n - 1; ++j) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1)
      ;
    if (j < i) swap(a[i], a[j]);
  }
  for (int m, mh = 1; (m = mh << 1) <= n; mh = m) {
    long long irev = 0;
    for (int i = 0; i < n; i += m) {
      long long w = expmod(theta, irev);
      for (int k = n >> 2; k > (irev ^= k); k >>= 1)
        ;
      for (int j = i; j < mh + i; ++j) {
        int k = j + mh;
        long long x = a[j] - a[k];
        x += MOD;
        x %= MOD;
        a[j] += a[k];
        a[j] %= MOD;
        a[k] = kali(w, x);
      }
    }
  }
  if (sign == -1)
    for (int i = 0; i < n; i += 1) a[i] = kali(a[i], expmod(n, MOD - 2));
}
void pkali(vector<long long>& res, vector<long long>& a, vector<long long>& b) {
  res.clear();
  int n = a.size() + b.size() - 1;
  for (int i = 1; i < n; i <<= 1)
    if (n & i) n += i;
  a.resize(n);
  b.resize(n);
  FFT(a);
  FFT(b);
  for (int i = 0; i < n; i += 1) res.push_back(kali(a[i], b[i]));
  FFT(res, -1);
}
string tostring(int x) {
  char dum[20];
  sprintf(dum, "%d", x);
  string ret(dum);
  return ret;
}
long long ans[40][1010];
inline void prework() {
  vector<long long> cur;
  cur.push_back(1);
  for (int i = 0; i < 1000; i += 1) cur.push_back(0);
  ans[0][0] = 1;
  for (int i = 1; i < 1001; i += 1) ans[0][i] = 0;
  for (int i = 1; i < 40; i += 1) {
    vector<long long> a, b;
    a.clear();
    b.clear();
    for (int j = 0; j < 1001; j += 1) a.push_back(cur[j]), b.push_back(cur[j]);
    vector<long long> c;
    c.clear();
    pkali(c, a, b);
    a.clear();
    b.clear();
    for (int j = 0; j < 1001; j += 1) a.push_back(c[j]), b.push_back(c[j]);
    cur.clear();
    pkali(cur, a, b);
    a.clear();
    b.clear();
    for (int j = 0; j < 1000; j += 1) ans[i][j + 1] = cur[j];
    ans[i][0] = 1;
    c.clear();
    for (int j = 0; j < 1001; j += 1) c.push_back(ans[i][j]);
    cur = c;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  prr = 3;
  prework();
  int kasus;
  cin >> kasus;
  while (kasus--) {
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    while (n != 1) {
      if ((n - 1) % 2 == 0) {
        cnt++;
        n--;
        n /= 2;
      } else
        break;
    }
    cout << ans[cnt][m] << endl;
  }
  return 0;
}
