#include <bits/stdc++.h>
using namespace std;
const int g = 2e5;
const int p = 7340033;
const int maxk = 4096;
const int maxq = 1e5 + 10;
int T, n, k, a[31][maxk];
int H, L, R[maxk], G[maxk];
int fan(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = (long long)ret * x % p;
    x = (long long)x * x % p;
    y >>= 1;
  }
  return ret;
}
void NTT(int *A, int f) {
  int i, j, l, tmp, len, gn;
  for (i = 0; i < L; i++)
    if (i < R[i]) swap(A[i], A[R[i]]);
  for (len = 2; len <= L; len <<= 1) {
    l = len >> 1;
    gn = fan(g, (p - 1 + f * (p - 1) / len) % (p - 1));
    for (i = 1; i < len; i++) G[i] = (long long)G[i - 1] * gn % p;
    for (i = 0; i < L; i += len)
      for (j = 0; j < l; j++) {
        tmp = A[i + j];
        A[i + j] = (tmp + (long long)G[j] * A[i + j + l]) % p;
        A[i + j + l] = (tmp + (long long)G[j + l] * A[i + j + l]) % p;
      }
  }
  if (f == -1)
    for (i = 0; i < L; i++) A[i] = (long long)A[i] * fan(L, p - 2) % p;
}
int main() {
  cin >> T;
  G[0] = a[0][0] = 1;
  int i, j, t;
  for (H = 0, L = 1; L < maxk; ++H, L <<= 1)
    ;
  for (i = 0; i < L; i++) R[i] = (R[i >> 1] >> 1) | ((i & 1) << (H - 1));
  for (i = 1; i <= 30; i++) {
    for (j = 0; j < maxk; j++) a[i][j] = a[i - 1][j];
    t = 2;
    while (t--) {
      NTT(a[i], 1);
      for (j = 0; j < maxk; j++) a[i][j] = (long long)a[i][j] * a[i][j] % p;
      NTT(a[i], -1);
    }
    for (j = 1001; j < maxk; j++) a[i][j] = 0;
    for (j = 1000; j; j--) a[i][j] = a[i][j - 1];
    a[i][0] = 1;
  }
  while (T--) {
    scanf("%d%d", &n, &k);
    i = 0;
    while (n > 1 && (n & 1)) ++i, n >>= 1;
    printf("%d\n", a[i][k]);
  }
  return 0;
}
