#include<iostream>
using namespace std;
int main()
{
int t,n,m;
cin>>t;
for(int q=1;q<=t;q++)
{
cin>>n>>m;
if(n%2==0)
{
if(m<=n/2)
{
cout<<m*2<<endl;
}
if(m>n/2)
{
cout<<(m-n/2)*2-1<<endl;
}
}
if(n%2==1)
{
if(m<=(n-1)/2)
{
cout<<m*2<<endl;
}
if(m>(n-1)/2)
{
cout<<(m-(n-1)/2)*2-1<<endl;
}
}
}
return 0;
}