#include <bits/stdc++.h>
using namespace std;
#define int long long
// bitset!!! at positon 1-12 somewhere, when it first differs x and y, we can check that position checking is 4096, we are
// overcounting. 12 choose 6 924, avoids collisions
// issue we are having: all 1s in x are in y, cannot determine whethe rit is x or y who is the one we want
// how do we use
// 000000111111 12 choose 6 1s or 0s
// each num from 1 to 920 has a mask. we guarentee that x has a bit = 1 while y has a bit = 0? x != y
vector<int> masker(925); // this is N -> mask translator
void query1(){ // check when mask of x and y differ by a bit
int n, t;
cin >> n >> t;
while(t--){
int x, y;
cin >> x >> y;
for(int h = 1; h <= 12; h++){
if( ((masker[x] >> (h-1)) & 1) == 1 && ((masker[y] >> (h-1)) & 1) == 0){
// first difference, place we can differentiate.
cout << h << '\n';
break;
}
}
}
}
void query2(){
int n, t;
cin >> n >> t;
while(t--){
int q, h;
cin >> q >> h;
if(masker[q] >> (h - 1)){
cout << "yes\n";
}else{
cout << "no\n";
}
}
}
void precompute(){
vector<int> masks;
for(int mask = 0; mask < (1 << 12); mask++){
if(__builtin_popcount(mask) == 6){
masks.push_back(mask);
}
}
masker.push_back(-1); // 0-> -1, we dont care
for(int i = 1; i <= 920; i++){
masker[i] = masks[i-1];
}
}
int32_t main(){
precompute();
int type;
cin >> type;
query1();
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
// bitset!!! at positon 1-12 somewhere, when it first differs x and y, we can check that position checking is 4096, we are
// overcounting. 12 choose 6 924, avoids collisions
// issue we are having: all 1s in x are in y, cannot determine whethe rit is x or y who is the one we want
// how do we use
// 000000111111 12 choose 6 1s or 0s
// each num from 1 to 920 has a mask. we guarentee that x has a bit = 1 while y has a bit = 0? x != y
vector<int> masker(925); // this is N -> mask translator
void query1(){ // check when mask of x and y differ by a bit
int n, t;
cin >> n >> t;
while(t--){
int x, y;
cin >> x >> y;
for(int h = 1; h <= 12; h++){
if( ((masker[x] >> (h-1)) & 1) == 1 && ((masker[y] >> (h-1)) & 1) == 0){
// first difference, place we can differentiate.
cout << h << '\n';
break;
}
}
}
}
void query2(){
int n, t;
cin >> n >> t;
while(t--){
int q, h;
cin >> q >> h;
if(masker[q] >> (h - 1)){
cout << "yes\n";
}else{
cout << "no\n";
}
}
}
void precompute(){
vector<int> masks;
for(int mask = 0; mask < (1 << 12); mask++){
if(__builtin_popcount(mask) == 6){
masks.push_back(mask);
}
}
masker.push_back(-1); // 0-> -1, we dont care
for(int i = 1; i <= 920; i++){
masker[i] = masks[i-1];
}
}
int32_t main(){
precompute();
int type;
cin >> type;
query2();
}