#include<stdio.h>
int main()
{
int t,D,I,P,i,j;
//freopen("in.txt","r",stdin);
while(scanf("%d",&t)==1&&t>0)
{
for(i=0;i<t;i++)
{
scanf("%d%d",&D,&I);
P=1;D--;
for (j=0;j<D;j++)
{
P= I&1 ? (P<<1) : (P<<1)+1;
I=(I+1)>>1;
}
printf("%d\n",P);
}
}
return 0;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.