#include <bits/stdc++.h>
using namespace std;
const int mod = 7340033;
int dp[55][1100];
int main() {
  dp[0][0] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i][0] = 1;
    for (int x = 0; x < 4; x++) {
      for (int j = 1000; j >= 1; j--) {
        int tmp = 0;
        for (int k = 0; k <= j; k++) {
          tmp = (tmp + (long long)dp[i - 1][k] * dp[i][j - k] % mod) % mod;
        }
        dp[i][j] = tmp;
      }
    }
    for (int j = 1000; j >= 1; j--) dp[i][j] = dp[i][j - 1];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int n, k;
    scanf("%d %d", &n, &k);
    int t = 0;
    while (n % 2 && n >= 3) {
      n /= 2;
      t++;
    }
    printf("%d\n", dp[t][k]);
  }
}
