// Arup Guha
// 8/31/2013
// Solution to 2013 UCF Locals Problem: Are We Stopping Again?

import java.util.*;
import java.io.*;

public class stopping {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("stopping.in"));
		int numCases = stdin.nextInt();

		// Process cases.
		for (int loop=0; loop<numCases; loop++) {

			// Get data.
			int dist = stdin.nextInt();
			int stop1 = stdin.nextInt();
			int stop2 = stdin.nextInt();
			System.out.println(dist+" "+stop1+" "+stop2);

			// Use Inclusion-Exclusion; add back in each multiple of the LCM of the two numbers.
			int lcm = stop1/gcd(stop1,stop2)*stop2;
			int ans = (dist-1)/stop1 + (dist-1)/stop2 - (dist-1)/lcm;
			System.out.println(ans);
		}

		stdin.close();
	}

	// Usual gcd function...
	public static int gcd(int a, int b) {
		if (a == 0) return b;
		if (b == 0) return a;
		return gcd(b, a%b);
	}
}