#include #include using namespace std; using namespace atcoder; using ll = long long; template using V = vector; ll solve(void){ ll n, a, b; cin >> n >> a >> b; ll na = floor_sum(n / a + 1, 1, -a, n) - n; ll nb = floor_sum(n + 1, b, -1, n) - n / b; ll nab = floor_sum(n / a + 1, b, -a, n) - n / b; return (na + nb - 2 * nab); } int main(void){ int t; cin >> t; while(t--){ cout << solve() << endl; } }