#include <bits/stdc++.h>
using namespace std;
const int MOD = 7340033;
template <class T>
void add(T &a, T b) {
  (a += (b % MOD + MOD) % MOD) %= MOD;
}
const int N = 28;
const int M = 1000;
vector<vector<long long>> dp(N + 1, vector<long long>(M + 1));
void init() {
  for (int i = 0; i <= N; i++) dp[i][0] = 1;
  for (int i = 0; i < N; i++) {
    vector<long long> d(M + 1);
    for (int j = 0; j <= M; j++)
      for (int j2 = 0; j + j2 <= M; j2++) {
        add(d[j + j2], dp[i][j] * dp[i][j2]);
      }
    for (int j = 0; j <= M; j++)
      for (int j2 = 0; j + j2 < M; j2++) {
        add(dp[i + 1][j + j2 + 1], d[j] * d[j2]);
      }
  }
}
int main() {
  init();
  auto height = [&](int n) {
    int res = 0;
    while (n > 1 && n % 2) res++, n /= 2;
    return res;
  };
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    cout << dp[height(n)][k] << endl;
  }
  return 0;
}
