#include <bits/stdc++.h>
using namespace std;
const long long MOD = 7340033;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<vector<long long> > dp(29, vector<long long>(1001, 0));
  for (int i = 0; i < 29; ++i) {
    dp[i][0] = 1;
  }
  for (int k = 1; k < 1001; ++k) {
    dp[0][k] = 0;
  }
  for (int i = 1; i < 29; ++i) {
    vector<long long> v(2048, 0);
    for (int j = 0; j < 1001; ++j) {
      for (int j2 = 0; j2 + j < 1001; ++j2) {
        v[j + j2] = (v[j + j2] + dp[i - 1][j] * dp[i - 1][j2]) % MOD;
      }
    }
    vector<long long> ans(2048, 0);
    for (int j = 0; j < 1001; ++j) {
      for (int j2 = 0; j2 + j < 1001; ++j2) {
        ans[j + j2] = (ans[j + j2] + v[j] * v[j2]) % MOD;
      }
    }
    for (int k = 1; k < 1001; ++k) {
      dp[i][k] = ans[k - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b, c = 0;
    cin >> a >> b;
    a++;
    while (!(a & 1)) {
      a = (a >> 1);
      ++c;
    }
    if (a == 1) --c;
    cout << dp[c][b] << endl;
  }
}
