#include <iostream>
#include "algorithm"
#include "math.h"
using namespace std;

struct circ {
	int x, y;
};
struct whrq {
	int w, h, r, q;
};
double cut(circ c, int x, whrq y) {
	if (abs(c.x - x) >= y.r) {  return double(y.h); }
	else if (abs(c.x - x) == 0) {  return double(abs(c.y - y.r)); }
	else {
		double a = double(abs(c.x - x)) / double(y.r);
		double b = acos(a);   
		double z = sin(b) * y.r;
		return c.y-z;
	}
}

int main()
{
	int x, c = 0, a; circ* arr; whrq y;
	double* b;
	cin >> y.w >> y.h >> y.r >> y.q;
	arr = new circ[y.q]; b = new double[y.q]; int j = 0;
	for (int i = 0; i < y.q; i++) {
		cin >> a;

		if (a == 1) {
			c++;
			cin >> arr[c - 1].x; cin >> arr[c - 1].y;
		}
		else {
			cin >> x;
			if (c == 0) { b[i] = double(y.h); j++; }
			else {
				double min = cut(arr[0], x, y);
				for (int i = 0; i < c; i++) {
					double z = cut(arr[i], x, y);
					if (z < min)min = z;
				}b[j] = min; j++;
			}

		}
	}
	for (int i = 0; i < j; i++) { printf("%.8f\n", b[i]); }
	return 0;

}
/**/