#include <iostream>
#include <math.h>

using namespace std;

long double r[1000000];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int W, H, R, Q;
	int pom,pom2,pom3=0;
	int x1=0, x2, y1=0;
	cin >> W >> H >> R >> Q;
	for (int i = 0;i < Q;i++) {
		cin >> pom;
		if (pom == 1) cin >> x1 >> y1;
		else {
			cin >> x2;
			if (x1 == 0 && y1 == 0) r[pom3++] = H;
			else {
				pom2 = R * R - (x1 - x2)*(x1 - x2);
				r[pom3++] = y1 - sqrt(pom2);
				if (r[pom3 - 1] > H) r[pom3 - 1] = H;
			}
		}
	}
	for (int i = 0;i < pom3;i++) {
		cout.precision(12);
		cout << fixed << r[i] << "\n";\
	}
}