#include <bits/stdc++.h>
const double PI = acos(-1.0);
const double EPS = 1E-9;
const int INF = (int)1E9;
using namespace std;
long long f[32][1200];
long long fm[5][1200];
void dp() {
  f[0][0] = 1;
  for (int lv = (1); lv <= (29); lv++) {
    memset(fm, 0, sizeof(fm));
    fm[0][0] = 1;
    for (int b = (1); b <= (4); b++) {
      for (int i = 0; i < (1001); i++)
        for (int j = 0; j < (1001); j++) {
          if (i + j > 1000) break;
          fm[b][i + j] += fm[b - 1][i] * f[lv - 1][j];
          fm[b][i + j] %= 7340033;
        }
    }
    f[lv][0] = 1;
    for (int i = 0; i < (1001); i++) {
      f[lv][i + 1] = fm[4][i];
    }
  }
}
int main() {
  int Q;
  memset(f, 0, sizeof(f));
  dp();
  cin >> Q;
  while (Q--) {
    int n, k;
    cin >> n >> k;
    int dep = 0;
    while (n % 2 == 1) {
      if (n >= 3) {
        dep++;
      } else {
        break;
      }
      n /= 2;
    }
    printf("%d\n", f[dep][k]);
  }
  return 0;
}
