#54321: Python解


alehan0214@gmail.com (吳忠和)


#有注釋
# strat
N = int(input())
for s in range(N):
    X, a, b = map(int, input().split())
    # 確保a是較大的面值,簡化遍歷
    if a < b :
        a, b = b, a
    min_coins = float('inf') # 初始化為無窮大,表示暫未找到解
    # 遍歷a硬幣的可能數量,從0到X//a
    for aq in range(X // a + 1):
        remainder = X - a * aq
        if remainder % b == 0:
            bq = remainder // b
            total = aq + bq
            if total < min_coins:
                min_coins = total
    # 輸出結果:找到解則輸出最小值,反之輸出-1
    print(min_coins if min_coins != float('inf') else -1)