#include <bits/stdc++.h>
using namespace std;
int nq, n;
long long f[40][2000];
long long g[40][2000];
long long oo = 7340033;
int val(int n) {
  int cnt = 0;
  while (n % 2) {
    if (n == 1) break;
    cnt++;
    n = (n - 1) / 2;
  }
  return cnt;
}
int main() {
  int n, nk;
  cin >> nq;
  for (int n = 0; n < 30; n++) f[n][0] = 1;
  int maxk = 1000;
  for (int n = 1; n < 30; n++) {
    for (int s = 0; s < maxk; s++)
      for (int i = 0; i <= s; i++) {
        g[n][s] += f[n - 1][i] * f[n - 1][s - i];
        g[n][s] %= oo;
      }
    for (int k = 1; k <= maxk; k++)
      for (int s = 0; s < k; s++) {
        f[n][k] += g[n][s] * g[n][k - 1 - s];
        f[n][k] %= oo;
      }
  }
  while (nq--) {
    cin >> n >> nk;
    n = val(n);
    cout << f[n][nk] << endl;
  }
  return 0;
}
