#include <bits/stdc++.h>   using namespace std;   const int m = 31;   const int maxn = 31;   long long n, k;   long long f[maxn + 5], g[maxn + 5];   void init() {     f[1] = g[1] = 1;     for (int i = 2; i <= m; i++) {       f[i] = (1LL << i * 2 - 2) + f[i - 1];       g[i] = (1LL << i) - 1 + g[i - 1];     }   }   int main() {     init();     long long T;     cin >> T;     while (T--) {       cin >> n >> k;       if (n > m) {         printf( YES %I64d n , n - 1);         continue;       }       int flg = -1;       for (int i = 0; i <= n; i++) {         if (k >= g[i] &&             k <= f[i] + f[n - i] * ((1ll << i) - 1) * ((1ll << i) - 1)) {           flg = i;           break;         }       }       if (~flg)         printf( YES %I64d n , n - flg);       else         printf( NO n );     }     return 0;   }   