#include <bits/stdc++.h>
using namespace std;
const int maxN = 33 + 1;
const int maxK = 1000 + 5;
const long long mod = 7340033;
long long d[maxN][maxK];
long long b[4][maxK];
int main() {
  ios_base::sync_with_stdio(false);
  d[0][0] = 1;
  for (int i = 1; i < maxN; i++) {
    d[i][0] = 1;
    memset(b, 0, sizeof(b));
    for (int j = 0; j < maxK; j++) b[0][j] = d[i - 1][j];
    for (int j = 0; j < maxK; j++) {
      for (int q = 1; q < 4; q++)
        for (int r = 0; j - r >= 0; r++)
          b[q][j] += b[q - 1][j - r] * b[0][r], b[q][j] %= mod;
      if (j) d[i][j] = b[3][j - 1];
    }
  }
  int T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (; n % 2 == 1 && n > 1; n /= 2, cnt++)
      ;
    cout << d[cnt][k] << endl;
  }
  return 0;
}
