#include <bits/stdc++.h> 
#define pb pusk_back
using namespace std;
int main()
{
	int w,q,k,i,j,l,p,e;
	e=0;
	//unsigned long long int r2;
	//vector <long double> rx;
	//vector <long double> ry;
 	double rx[100000],ry[100000],x,yp,y,min,h,r2,r,O[100000];
	scanf("%d",&w);
	scanf("%lf",&h);
	scanf("%lf",&r);
	scanf("%d",&q);
	r2=pow(r,2.0);
	//cout<<"ovde smo"<<endl;
	//printf("%.2lf\n",r2);
	k=1;
	i=0;
	gore:
	scanf("%d",&j);
	switch (j)
	{
		case 1:
			scanf("%lf",&rx[i]);
			scanf("%lf",&ry[i]);
			if (k==q)
			{
				goto kraj;
			}
			else
			{
				k++;
				i++;
				goto gore;
			}
			break;
		case 2:
			scanf("%lf",&x);
			min=h+1;
			for (l=0;l<=i-1;l++)
			{
				yp=r2-((x-rx[l])*(x-rx[l]));
				
				if (yp<0.0)
				{
					y=h;
				}
				else
				{
					y=ry[l]-sqrt(yp);
				}
				
				if (y<min)
				{
					min=y;
				}
			}
			if (min<=0.0)
			{
				//printf("0\n");
				O[e]=0;
				e++;	
			}
			else 
			{
				if (min>=h)
				{
				 //printf("%.12lf\n",h);
				 O[e]=h;
				 e++;
				}
				else
				{
				 //printf("%.12lf\n",min);
				 O[e]=min;
				 e++;
				}
			}
			if (k==q)
			{
				goto kraj;
			}
			else 
			{
				k++;
				goto gore;
			}
			break;
	}
	kraj:
		if (e!=0)
		{
			for(i=0;i<e;i++)
			{
				printf("%.12lf\n",O[i]);
			}
		}
}