#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	long double W, H, R, Q, p = -1, q = -1, k = 1, n = 0;
	double x, y;
	scanf("%Lf%Lf%Lf%Lf", &W, &H, &R, &Q);
	for (int caase = 0; caase < Q; caase++) {
		int kejs;
		scanf("%d", &kejs);
		if (kejs == 1) 
			scanf("%Lf%Lf", &p, &q);
		else if (kejs == 2) {
			scanf("%lg", &x);
			if (p == -1 || q == -1) {
				printf("%.9Lf\n", H);
				continue;
			}
			y = -(sqrt(pow(R, 2) - pow(x - p, 2))) + q;
			if(y > H)
				printf("%.9Lf\n", H);
			else
				printf("%.11lg\n", y);
		}
	}
	return 0;
}