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

int main(void)
{
	//
	// Unos parametara.
	//

	char k;
	long i;
	long w,h,r,q;
	
	long xk=0, yk=0, xi=0;

	printf ("Unesite W,H,R i Q : ");
	scanf ("%ld %ld %ld %ld", &w, &h, &r, &q);
	
	for (i=0; i<q; i++)
	{
		printf ("> ");
		scanf ("%d", &k);
		
		if (k==1)
		{
			long tmp_xk, tmp_yk;
			scanf ("%ld %ld", &tmp_xk, &tmp_yk);

			// Ako je centar kružnice po y osi ispod ili na istoj visini kao prethodni krug upamti njegov centar.
			if (tmp_yk <= yk || (xk==0 && yk==0))
			{
				xk=tmp_xk;
				yk=tmp_yk;
			}
		}
		else if (k==2)
		{
			scanf ("%ld", &xi);

			if (xk==0 && yk==0)
				printf("%1.15lf\n",(double)h);
			else
			{
				double y;
				y=(double)yk-sqrt(((double)r*(double)r)-(((double)xi-(double)xk)*((double)xi-(double)xk)));
				
				if (y>(double)h)
					y=h;
				
				printf ("%1.15lf\n",y);
			}
		}
	}
}