#include <bits/stdc++.h>
using namespace std;
const int Maxn = 32, Maxm = 1200, Mo = 7340033, oo = INT_MAX >> 2;
int d, i, j, k, n, cs;
long long f[Maxn][Maxm], tmp[Maxm];
int main() {
  ios::sync_with_stdio(0);
  f[0][0] = 1;
  for (d = 1; d <= 30; d++) {
    memset(tmp, 0, sizeof(tmp));
    tmp[0] = 1;
    for (i = 1; i <= 4; i++)
      for (j = 1000; j >= 0; j--)
        for (k = 1; k <= j; k++) {
          tmp[j] += tmp[j - k] * f[d - 1][k] % Mo;
          tmp[j] %= Mo;
        }
    f[d][0] = 1;
    for (i = 1; i <= 1000; i++) f[d][i] = tmp[i - 1];
  }
  cin >> cs;
  while (cs--) {
    cin >> n >> k;
    d = 0;
    while (n % 2 && n > 1) {
      d++;
      n /= 2;
    }
    cout << f[d][k] << endl;
  }
}
