for _ in range(int(input())): N, B = map(int, input().split()) print(N // (B + 1))