#include <bits/stdc++.h>
using namespace std;
int n, q, k;
long long f[35][1100], f1[35][1100];
int main() {
  f[0][0] = 1;
  for (int i = 1; i < 35; i++) {
    f[i][0] = 1;
    for (int j = 0; j < 1050; j++)
      for (int k = 0; k < 1050 - j; k++)
        f1[i][j + k] = (f1[i][j + k] + f[i - 1][j] * f[i - 1][k]) % 7340033;
    for (int j = 0; j < 1050; j++)
      for (int k = 0; k < 1050 - j; k++)
        f[i][j + k + 1] = (f[i][j + k + 1] + f1[i][j] * f1[i][k]) % 7340033;
  }
  cin >> q;
  for (; q; q--) {
    scanf("%d%d", &n, &k);
    int l = 0;
    while ((n > 1) && (n % 2)) {
      n /= 2;
      l++;
    }
    printf("%d\n", f[l][k]);
  }
  return 0;
}
