#include <bits/stdc++.h>
using namespace std;
int q, n, k;
long long t[1010], dp[32][1010] = {0};
int main() {
  dp[0][0] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i][0] = 1;
    memset(t, 0, sizeof(t));
    for (int j = 0; j <= 1000; j++)
      for (int k = 0; k <= 1000 - j; k++)
        t[j + k] = (t[j + k] + dp[i - 1][j] * dp[i - 1][k]) % 7340033;
    for (int j = 0; j <= 1000; j++)
      for (int k = 0; k <= 1000 - j; k++)
        dp[i][j + k + 1] = (dp[i][j + k + 1] + t[j] * t[k]) % 7340033;
  }
  cin >> q;
  while (q--) {
    scanf("%d%d", &n, &k);
    int h = 0;
    while (n > 1 && n % 2 == 1) {
      n = n / 2;
      h++;
    }
    cout << dp[h][k] << "\n";
  }
  return 0;
}
