#include <stdio.h>
#include <math.h>
int main()
{
	int W,H,R,Q;
	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&R);
	scanf("%d",&Q);
	int i=0,x=0,y=0,br=0,x1,a;
    double niz[10000];
    while(i<Q)
    {
    	scanf("%d",&a);
    	switch(a)
    	{
    		case 1:
    			{
    				scanf("%d",&x);
    				scanf("%d",&y);
				}
				break;
			case 2:
				{
					scanf("%d",&x1);
					if(x==0&&y==0)
					{
						niz[br]==(double)H;
						br++;
					}
					else
					{
						niz[br]=double(y)-(double)sqrt(double(R)*(double)R-((double)x-(double)x1)*((double)x-(double)x1));
						if(niz[br]==(double)y)
							niz[br]=H;
						br++;
					}
				}
		}
		i++;
	}
	for(int i=0;i<br;i++)
		printf("%.9lf\n",niz[i]);
    return 0;
}