#include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
void smax(P &a, Q b) {
  if (b > a) a = b;
}
template <class P, class Q>
bool in(const P &a, const Q &b) {
  return a.find(b) != a.end();
}
const int LOG = 32, MAXN = 1024, MOD = 7340033;
int dp[MAXN][MAXN];
int main() {
  dp[0][0] = dp[1][0] = dp[1][1] = 1;
  for (int i = (1); i < int(LOG - 1); ++i) {
    dp[i + 1][0] = 1;
    for (int rep = (0); rep < int(4); ++rep)
      for (int j = MAXN - 1; j >= 0; j--)
        for (int k = 1; j + k < MAXN; k++)
          (dp[i + 1][j + k] += 1LL * dp[i][k] * dp[i + 1][j] % MOD) %= MOD;
    for (int j = MAXN - 1; j >= 1; j--) dp[i + 1][j] = dp[i + 1][j - 1];
  }
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    int l = 0;
    while (n > 1 && n % 2) n /= 2, l++;
    cout << dp[l][k] << "\n";
  }
  return 0;
}
