#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
using namespace std;
const int N = 1e5 + 5;
int r, i, l, w, h, q, x, y;
double p, v[N];

double duz(int xk, int yk, int x) {
	int d = abs(xk - x);
	return yk - sqrt(r * r - d * d);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(14);

	cin >> w >> h >> r >> q;
	for (i = 0; i <= w; i++)v[i] = h;
	
	while (q--) {
		cin >> l;
		if (l < 2) {
			cin >> x >> y;
			for (i = x; i >= 0 && x-r<=i; --i) {
				p = duz(x, y, i);
				v[i] = min(v[i], p);
			}
			for (i = x+1; i <= w && x + r >= i; ++i) {
				p = duz(x, y, i);
				v[i] = min(v[i], p);
			}
		}
		else {
			cin >> x;
			cout << v[x] << '\n';
		}
	}
}