import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.NoSuchElementException; class Main { public static void main(String[] args) { new Main().run(); } int exact(int N, int A, int B) { int ret=0; for (int i=1;i<=N;++i) { for (int j=1;j<=N-i;++j) { if (i%A!=0&&j%B!=0) continue; ++ret; } } return ret; } void solve() { FastScanner sc=new FastScanner(); PrintWriter pw=new PrintWriter(System.out); int T=sc.nextInt(); while (T-->0) { int N=sc.nextInt(); int A=sc.nextInt(); int B=sc.nextInt(); int i=1; long ans=(long)(N/A)*(N-A+N%A)/2+(long)(N/B)*(N-B+N%B)/2; while (i