#include<stdlib.h>
#include<stdio.h>
#include<math.h>
float ispis[1000000];
int main(){
	float W,H,R,Q,xi,yi,xx,y,i,y1,y2;int indikator,j=0;
	scanf("%f%f%f%f",&W,&H,&R,&Q);xi=H;yi=W;
	for(i=0;i<Q;i++){
		scanf("%d",&indikator);
		if(indikator==1){
			scanf("%f%f",&xi,&yi);
		}
		else if(indikator==2){
			scanf("%f",&xx);
			if(i==0) y=H;
			else{
			y1=yi+sqrt(R*R-(xx-xi)*(xx-xi));
			y2=yi-sqrt(R*R-(xx-xi)*(xx-xi));
			if(y1<y2 && y1>0) y=y1;
			else y=y2;
			if(y>H) y=H;
			}
			ispis[j++]=y;
		}
	}
	for(int k=0;k<j;k++){
		printf("%.9f\n",ispis[k]);
	}
}