#include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long qp(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long z = qp(x, y / 2);
  z = z * z % 1000000007;
  if (y & 1) z = z * x % 1000000007;
  return z;
}
long long wyx = 7340033, n, m, i, j, k, t, dp[35][1005], dp2[35][1005];
long long suff(long long x) {
  long long s = 0;
  while (x != 1 && (x & 1)) {
    s++;
    x /= 2;
  }
  return s;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> t;
  for (i = 1; i <= 33; i++) {
    dp2[i][0] = 1;
    for (j = 1; j <= 1000; j++) {
      for (k = 0; k <= j; k++) {
        dp2[i][j] += dp[i - 1][k] * dp[i - 1][j - k];
        dp2[i][j] %= wyx;
      }
    }
    dp[i][0] = 1;
    for (j = 1; j <= 1000; j++) {
      for (k = 0; k < j; k++) {
        dp[i][j] += dp2[i][k] * dp2[i][j - k - 1];
        dp[i][j] %= wyx;
      }
    }
  }
  dp[0][0] = 1;
  while (t--) {
    cin >> n >> m;
    cout << dp[suff(n)][m] << endl;
  }
  return 0;
}
