#include #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } signed main() { int T; cin >> T; while (T--) { int d, x, y; cin >> d >> x >> y; int g = gcd(x, y); int xg = x / g; int yg = y / g; int r = min((d - y) / xg, x / yg); int xb = x - yg * r; int yb = y + xg * r; int area = abs(x * yb - xb * y); cout << area << endl; } return 0; }