#include <bits/stdc++.h>
const int maxn = 1005;
const int Mod = 7340033;
int f[33][maxn], g[33][maxn];
void Gao(int *a, int *b) {
  int i, j;
  for (i = 0; i <= 1000; i++)
    for (j = 0; j <= i; j++) a[i] = ((long long)b[j] * b[i - j] + a[i]) % Mod;
}
int main() {
  int i;
  f[0][0] = 1;
  for (i = 1; i < 33; i++) {
    Gao(g[i - 1], f[i - 1]);
    Gao(f[i] + 1, g[i - 1]);
    f[i][0] = 1;
  }
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, k, cnt = 0;
    scanf("%d%d", &n, &k);
    while (n % 2 != 0) {
      cnt++;
      n /= 2;
    }
    if (n == 0) cnt--;
    printf("%d\n", f[cnt][k]);
  }
  return 0;
}
