#include #include #include using namespace atcoder; typedef long long ll; int main() { ll T; scanf("%lld", &T); assert(1 <= T && T <= 1e4); while (T--) { ll n, a, b; scanf("%lld%lld%lld", &n, &a, &b); assert(2 <= n && n <= 1e9); assert(1 <= a && a <= 1e9); assert(1 <= b && b <= 1e9); ll ans = floor_sum(n/a, 1, -a, n-a) + floor_sum(n/b, 1, -b, n-b) - floor_sum(n/a, b, -a, n-a); printf("%lld\n", ans); } return 0; }