与运算
0&n=0
1&奇数=1
1&偶数=0
#include <bits/stdc++.h>
//dfs 大法师
#define ll long long
using namespace std;
const int mod=20100403;
const int Inf=0x3f3f3f3f;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
int m1[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int m2[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
void Get_Time()
{
time_t timep;
time(&timep); //获取从1970至今过了多少秒,存入time_t类型的timep
printf("%s", ctime(&timep));//用ctime将秒数转化成字符串格式,输出:Thu Feb 28 14:14:17 2019
}
void solve()
{
int t;
cin>>t;
while(t--)
{
ll n,k;
cin>>n>>k;
if(n==4&&k==3){cout<<-1<<endl;continue;}
ll d=n-1-k;
if(k==n-1)
{
cout<<k<<" "<<k-1<<endl;
cout<<0<<" "<<n-1-3<<endl;
cout<<1<<" "<<3<<endl;
for(int a=0;a<n/2;a++)
{
if(a!=0&&a!=1&&a!=n-k&&a!=3)cout<<a<<" "<<n-1-a<<endl;
}
}
else
if(k!=0){
cout<<0<<" "<<d<<endl;
cout<<k<<" "<<n-1<<endl;
for(int a=0;a<n/2;a++)
{
if(a!=0&&a!=k&&a!=n-1-k)cout<<a<<" "<<n-1-a<<endl;
}
}
else
{
for(int a=0;a<n/2;a++)
cout<<a<<" "<<n-1-a<<endl;
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
int t;cin>>t;
while(t--){
int a,b;cin>>a>>b;
int ans=b-a;
if((b|a)==b)
{
puts("1");continue;
}
for(int i=1;i+1<=ans;i++)
{
if(((a+i)|b)==b||((b+i)|a)==b+i) ans=i+1;
}
cout<<ans<<endl;
}
}