#include <bits/stdc++.h>
using namespace std;
long long dp[32][1023], dp1[32][1023];
int main() {
  for (int i = 1; i <= 30; i++) {
    dp[i][0] = dp1[i][0] = 1;
  }
  for (int i = 2; i <= 30; i++) {
    dp[i][1] = 1;
    dp1[i][1] = 2;
    for (int j = 2; j <= 1000; j++) {
      for (int k = 0; k <= j; k++) {
        dp[i][j] += (dp1[i - 1][k] * dp1[i - 1][j - k - 1]) % 7340033;
      }
      for (int k = 0; k <= j; k++) {
        dp1[i][j] += (dp[i][k] * dp[i][j - k]) % 7340033;
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    if (!k) {
      cout << 1 << endl;
      continue;
    }
    int ans = 0;
    while (n % 2 == 1) {
      n = (n - 1) / 2;
      ans++;
    }
    if (n != 0) ans++;
    cout << (dp[ans][k]) % 7340033 << endl;
  }
  return 0;
}
