#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
long long LCM(long long a, long long b) { return a * (b / GCD(a, b)); }
const double EPS = 10e-9;
const long long INF = (1LL << 30);
using namespace std;
template <typename T>
string toString(T t) {
  stringstream ss;
  ss << t;
  return ss.str();
}
int main() {
  const long long MAXK = 1000, prime = 7340033;
  vector<vector<long long> > dp(32, vector<long long>(MAXK + 1, 0));
  vector<vector<long long> > dp2(32, vector<long long>(MAXK + 1, 0));
  for (int k = 0; k <= (31); ++k) {
    dp2[k][0] = 1;
    dp[k][0] = 1;
  }
  for (int m = 1; m <= (31); ++m) {
    for (int k = 1; k <= (MAXK); ++k) {
      for (int k1 = 0; k1 <= (k); ++k1) {
        dp2[m][k] += dp[m - 1][k - k1] * dp[m - 1][k1];
        if (dp2[m][k] >= prime) dp2[m][k] %= prime;
      }
    }
    for (int k = 1; k <= (MAXK); ++k) {
      for (int k1 = 0; k1 <= (k - 1); ++k1) {
        dp[m][k] += dp2[m][k - k1 - 1] * dp2[m][k1];
        if (dp[m][k] >= prime) dp[m][k] %= prime;
      }
    }
  }
  int Q;
  cin >> Q;
  for (int q = 0; q < (Q); ++q) {
    int N, K;
    cin >> N >> K;
    int pw = 0;
    while ((N + 1) % 2 == 0 && N > 1) {
      N /= 2;
      pw++;
    }
    cout << dp[pw][K] << endl;
  }
  return 0;
}
