#includetypedef long long LL; LL n; LL get(int x){return (1+n/x)*(n/x)*x/2;} LL gcd(int a,int b){return b?gcd(b,a%b):a;} LL lcm(int a,int b){return a/gcd(a,b)*b;} int main() { int T;scanf("%d",&T); while(T--) { int a,b;scanf("%lld%d%d",&n,&a,&b); printf("%lldn",get(a)+get(b)-get(lcm(a,b))); } return 0; }



