#include <bits/stdc++.h>
using namespace std;
struct _ {
  _() { ios_base::sync_with_stdio(0); }
} _;
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
  o << "(" << t.first << ", " << t.second << ")";
  return o;
}
template <class T>
string tostring(T first, int len = 0, char c = '0') {
  stringstream ss;
  ss << first;
  string r = ss.str();
  if (r.length() < len) r = string(len - r.length(), c) + r;
  return r;
}
template <class T>
void PV(T a, T b, int n = 0, int w = 0, string s = " ") {
  int c = 0;
  while (a != b) {
    cout << tostring(*a++, w, ' ');
    if (a != b && (n == 0 || ++c % n))
      cout << s;
    else
      cout << "\n";
    cout.flush();
  }
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
const long long linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 7340033;
const int N = 111111;
map<int, int> ID;
int dp[31][1001];
int main() {
  for (int i = 0; i <= 30; i++) ID[(1 << i) - 1] = i - 1;
  dp[0][0] = 1;
  for (int i = 1; i <= 30; i++) {
    int *p = dp[i - 1];
    int p2[1001] = {};
    for (int first = 0; first <= 1000; first++)
      for (int second = 0; first + second <= 1000; second++)
        p2[first + second] =
            (p2[first + second] + (long long)p[first] * p[second]) % mod;
    dp[i][0] = 1;
    for (int k = 1; k <= 1000; k++) {
      int &r = dp[i][k];
      for (int first = 0; first <= k - 1; first++) {
        r = (r + (long long)p2[first] * p2[k - 1 - first]) % mod;
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    int m = 0;
    while ((n - 1) % 2 == 0) {
      n /= 2;
      m++;
    }
    if (n == 0) m--;
    cout << dp[m][k] << endl;
  }
  return 0;
}
