#include<iostream>
#include<cmath>
using namespace std;
long double izracunaj(long double xc,long double xp,long double R)
{
	long double distanca;
	distanca=(long double)sqrt(R*R-(xc-xp)*(xc-xp));
	return distanca;
}
main()
{
	int sirina,visina,R,Q,izbor,x=0,y=0,prava,i=0;
	scanf("%d%d%d%d",&sirina,&visina,&R,&Q);
	long double rezultat[Q],temp,probaj=1;
	for(int brojac=0;brojac<Q;brojac++)
	{
		scanf("%d",&izbor);
		if(izbor==1)
			scanf("%d%d",&x,&y);
		else
		{
			scanf("%d",&prava);
			if(x==0&&y==0)
			{
				rezultat[i]=(long double)visina;
				i++;
				x=0;
				y=0;
			}
			else
			{
				temp=izracunaj((long double)x,(long double)prava,(long double)R);
				if(temp==0)
				{
					rezultat[i]=(long double)visina;
					i++;
				}
				else
				{
					rezultat[i]=(long double)y-temp;
					i++;
				}
			}
		}
	}
	for(int j=0;j<i;j++)
		printf("%.9Lf\n",rezultat[j]);
}