#include <bits/stdc++.h>
using namespace std;
int f[35][1005][5];
void preprocess() {
  int i, j, k, l;
  for (i = 0; i <= 1000; i++)
    f[0][i][0] = f[0][i][1] = f[0][i][2] = f[0][i][3] = 0;
  i = 0;
  f[0][i][0] = f[0][i][1] = f[0][i][2] = f[0][i][3] = 1;
  for (i = 1; i < 31; i++) {
    f[i][0][0] = 1;
    for (j = 1; j <= 1000; j++) f[i][j][0] = f[i - 1][j - 1][2];
    for (k = 1; k <= 2; k++)
      for (j = 0; j <= 1000; j++) {
        f[i][j][k] = 0;
        for (l = 0; l <= j; l++)
          f[i][j][k] = (f[i][j][k] +
                        (((long long int)f[i][l][k - 1] * f[i][j - l][k - 1]) %
                         7340033)) %
                       7340033;
      }
  }
}
int finddepth(int n) {
  int d = 0;
  while (n > 1 && n % 2 != 0) {
    n = (n - 1) / 2;
    d++;
  }
  return d;
}
int main() {
  int q;
  int n, k;
  preprocess();
  cin >> q;
  while (q--) {
    cin >> n >> k;
    cout << f[finddepth(n)][k][0] << endl;
  }
  return 0;
}
