#include<stdio.h>
#include<math.h>

double res[100000];
int main()
{
	long xk[100000];
long yk[100000];
	int po;
	double min;
	long xi,yi,xx,yy,br=0,brr=0;;
	//yy je trazeno
	long w,h,R,q;
	
	scanf("%ld %ld %ld %ld",&w,&h,&R,&q);
	
    long rsq=pow(R,2);
    
	for (long i=0;i<q;i++)
	{
		
		 
	   
		scanf("%d",&po);
		
		if(po==1)
		{
			scanf("%ld %ld",&xi,&yi);
			
		xk[br]=xi;
		yk[br]=yi;
		br++;
		
			
		}
		else
		{
			scanf("%ld",&xx);
		
				min=100020;
			
		
			
		
		    
			
			
		
			for(long j=0;j<br;j++)
			{
				if(   xx<=xk[j] +R&&xx>=xk[j]-R           &&     min>-sqrt(   rsq  -pow(xx-xk[j],2)                )+yk[j]     )
				min=-sqrt(   rsq  -pow(xx-xk[j],2)                )+yk[j];
			
			}
			
			if((double)h<min)
			min=(double)h;
			
			
			
			res[brr]=min;
			brr++;
		
		

	    	}

		
	
    }   
	
	 for(long j=0;j<brr;j++)
	   printf("\n%.12lf ",res[j]);
	

	return 0;
}