#include<bits/stdc++.h>
using namespace std;
long long ans=0,t=0,k,T,n,x;
int main(){
ios::sync_with_stdio(false);
cin>>T;
while(T--){
cin>>n>>x;
ans=0,t=0,k=x;
if(n==1||n==2){
cout<<x<<'\n';
continue;
}
if(x%2==0){
while(x%2==0){
t++;
x/=2;
}
if(t+1==n){
cout<<k<<'\n';
continue;
}
}
if(x%2==1){
cout<<(x << n-2)<<'\n';
continue;
}
}
return 0;
}