T=int(input()) ans=[] for _ in range(T): N,B=map(int,input().split()) ans.append(N//(B+1)) import sys sys.stdout.write('\n'.join(map(str,ans))+'\n')