#include <cstdio>

int main() {
	double x, y;
	scanf("%lf %lf", &x, &y);
	double prop = x / y;
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		double a;
		char c;
		scanf("%lf %c", &a, &c);
		if (c == 'A') a /= prop;
		else a *= prop;
		printf("%.10lf\n", a);
	}
	return 0;
}
