#include <bits/stdc++.h>

using namespace std;
double remaining[100000];

int min_int(int a,int b)
{
	if(a<b) return a;
	return b;
}

int max_int(int a,int b)
{
	if(a>b) return a;
	return b;
}

double min_double(double a,double b)
{
	if(a<b) return a;
	return b;
}

int main(int argc, char** argv) {
	int w,h,r,q;
	int i,op,j;
	int x,y,a,b;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>w>>h>>r>>q;
	cout<<fixed<<showpoint<<setprecision(12);
	for(i=0;i<=w;i++) remaining[i]=h;
	for(i=0;i<q;i++)
	{
		cin>>op;
		if(op==1)
		{
			cin>>x>>y;
			a=max_int(0,x-r);
			b=min_int(w,x+r);
			for(j=a;j<=b;j++)
			{
				remaining[j]=min_double(remaining[j],y-sqrt(r*r-(x-j)*(x-j)));
			}
		}
		else
		{
			cin>>x;
			cout<<remaining[x]<<endl;
		}
	}
	return 0;
}