#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
using namespace std;
const int N = 1e5 + 5;
int r, n, i, j, l, w, h, q, x, y, jx, jy, lx, ly;
double p, d;
map<int, int> k;

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

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

	cin >> w >> h >> r >> q;

	while (q--) {
		cin >> l;
		if (l < 2) {
			cin >> x >> y;
			auto it = k.find(x);
			if (it == k.end()) {
				k[x] = y;
			}
			else if (it->second > y) {
				it->second = y;
			}
		}

		else {
			cin >> x;
			auto itm = k.lower_bound(x);
			auto it = itm;
			jx = jy = 1e9;
			p = h;

			if (it != k.begin()) {
				for (it; it != k.begin(); it--) {
					if (x - r > it->second)break;

					lx = x - it->first;
					ly = it->second;

					if (lx > jx&& ly > jy)continue;

					d = duz(lx, ly);
					if (p > d) {
						p = d;
						jx = lx;
						jy = ly;
					}
				}
			}
			for (itm; itm != k.end(); itm++) {
				if (x + r < itm->second)break;

				lx = itm->first - x;
				ly = itm->second;

				if (lx > jx&& ly > jy)continue;

				d = duz(lx, ly);
				if (p > d) {
					p = d;
					jx = lx;
					jy = ly;
				}
			}

			cout << p << '\n';
		}
	}
}