#include <bits/stdc++.h>

using namespace std;

double v[100010];

vector <double> m;

int main()
{
	int h, w, r, q;
	
	cin >> w >> h >> r >> q;
	
	for(int i = 0; i < 100001; i++) v[i] = double(h);
	
	
	for(int i = 0; i < q; i++)
	{
		 int a;
		 
		 cin >> a;
		 
		 if(a == 1)
		 {
			int x, y;
			
			cin >> x >> y;
			
			int H = y - h;
			
			int t = sqrt(r * r - H * H);
			
			for(int i = max(0, x - t); i < min(w, x + t); i++)
			{
				v[i] = min(v[i], double(y) - sqrt(r * r - (x - i) * (x - i)));
			}
		 }
		 else
		 {
		 	int x;
		 	
		 	cin >> x;
		 	
		 	m.push_back(v[x]);
		 }
	}
	
	
	int n = m.size();
	
	for(int i = 0; i < n; i++) printf("%.9f\n", m[i]);
	
	return 0;
}