import java.util.*;

class solution {
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		double prop = x / y;
		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			double bef = sc.nextDouble();
			String C = sc.next().trim();
			if (C.equals("A")) bef /= prop;
			else bef *= prop;
			System.out.println(bef);
		}
	}
}
