N=10**8 S=int(input()) for i in range(S): a,b=map(int,input().split()) ans=N//b if a%2==0: ans+=2 print(ans)