#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;
double p, d;
map<int, int> k;

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(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 itl = k.lower_bound(x-r);
			auto itr = k.upper_bound(x + r);
			p = h;
			for(itl;itl!=itr;++itl){
				p = min(p, duz(itl->first, itl->second, x));
			}
			cout << p << '\n';
		}
	}
}