#include <bits/stdc++.h>
using namespace std;
const int N = 1000048;
const int mod = 7340033;
long long dp1[31][1010], dp2[31][1010];
int work(int x) {
  int ret = 0;
  while ((x & 1) && x > 1) x >>= 1, ret++;
  return ret;
}
int main() {
  for (int i = 0; i <= 30; i++) dp1[i][0] = 1;
  for (int h = 1; h <= 30; h++) {
    for (int i = 0; i <= 1000; i++) {
      for (int j = 0; j <= i; j++) {
        dp2[h][i] += dp1[h - 1][j] * dp1[h - 1][i - j] % mod;
        dp2[h][i] %= mod;
      }
    }
    for (int i = 1; i <= 1000; i++) {
      for (int j = 0; j < i; j++) {
        dp1[h][i] += dp2[h][j] * dp2[h][i - j - 1] % mod;
        dp1[h][i] %= mod;
      }
    }
  }
  int ca;
  for (scanf("%d", &ca); ca--;) {
    int n, k;
    scanf("%d%d", &n, &k);
    cout << dp1[work(n)][k] << endl;
  }
  return 0;
}
