for _ in range(int(input())): n,k=map(int,input().split()) ans=0;cur=1;sum=1 while sum