#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

// 模拟兑换过程
int simulate(int honey_start, int ginger_start, int a, int b) {
    int honey_empty = honey_start;
    int ginger_empty = ginger_start;
    int total = honey_start + ginger_start; // 初始喝到的数量

    // 只要还能换,就死循环(内部逻辑保证会停)
    while (honey_empty >= a || ginger_empty >= b) {
        int new_ginger = honey_empty / a; // 蜂蜜瓶换生姜
        int new_honey = ginger_empty / b; // 生姜瓶换蜂蜜

        // 喝掉换来的
        total += new_ginger + new_honey;
        
        // 更新空瓶状态:剩下的旧瓶 + 新喝出来的瓶
        honey_empty = (honey_empty % a) + new_honey;
        ginger_empty = (ginger_empty % b) + new_ginger;
    }
    return total;
}

int main() {
    int k;
    cin >> k;
    while(k--) {
        int n, a, b;
        cin >> n >> a >> b;

        int max_drunk = 0;

        // 【核心修改】:枚举所有可能的初始购买方案
        // i 代表买蜂蜜可乐的数量,n-i 代表买生姜可乐的数量
        for (int i = 0; i <= n; i++) {
            int current = simulate(i, n - i, a, b);
            max_drunk = max(max_drunk, current);
        }

        printf("%d\n", max_drunk);
    }
    return 0;
}