#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long #define rep(i, m, n) for (ll i = m; i < n; i++) #define rrep(i, m, n) for (ll i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define HOUT(S) cout << setprecision(50) << S << endl #define pint pair<ll, ll> #define tint tuple<ll, ll, ll> #define endl "\n" #define mod 1000000007LL #define MAX 100010LL #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value != 0>::type fill_v(U& u, const V... v) { u = U(v...); } template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value == 0>::type fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); } ll gcd(ll a, ll b) { if(b > a) swap(a, b); if(b == 0) return a; else return gcd(b, a % b); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll t; ll d, x, y; cin >> t; while(t--) { cin >> d >> x >> y; ll g = gcd(x, y); ll u = x / g; ll v = y / g; ll ans = 0; if(x == 0) ans = y * d; else if(y == 0) ans = x * d; else { ll n = min((d - x) / v, y / u); ll m = min((d - y) / u, x / v); ans = (x * u + y * v) * max(n, m); } cout << ans << endl; } }