#include<iostream>
#include<list>
#include<cmath>
#include<iomanip>
using namespace std;

struct Kord{
	int x, y;
	long double dist = -1;
};

list<Kord> niz[100000];
list<Kord>::iterator it;

int W,R, Q;
long double H;
char op;
int x, y;
int i;
long double min_dist;
Kord Krug;
long double yeet;
long double rez[10000];
int br;

long double Calculate(Kord krug, int X){
	yeet = krug.y - sqrt(R*R - (krug.x - X) * (krug.x - X));
	return (yeet > 0) ? yeet : 0;
}


int main(){
	cout << fixed;
	cout << setprecision(12);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	cin >> W >> H >> R >> Q;
	
	while (Q--){
		cin >> op;
		if (op == '1'){
			cin >> Krug.x >> Krug.y;
			for (i = Krug.x - R + 1; i < Krug.y + R; i++) niz[i].push_back(Krug);
		}
		else {
			cin >> x;
			if (niz[x].empty()) rez[br] = H, br++;
			else{
				it = niz[x].begin();
				if ((*it).dist == -1) (*it).dist = Calculate(*it, x);
				min_dist = (*it).dist;
				it++;
				for (; it != niz[x].end(); it++){
					if ((*it).dist == -1) (*it).dist = Calculate(*it, x);
					min_dist = max(min_dist,(*it).dist);
				}
			//	cout << min_dist << '\n';
				rez[br] = min_dist, br++;
			}
		}
	}
	for (i = 0; i < br; i++) cout << rez[i] << endl;
	return 0;
}