#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double visina(long double r,long double xi,long double yi,long double x1)
{
    return yi-sqrt(r*r-(xi-x1)*(xi-x1));
}
struct pet
{
    long double x,y;
};
double racunaj(long double h,pet p[],int i,int j,long double x1,long double r)
{
    double mini;
    mini=h;
    for(int k=0;k<j;k++)
        if(p[k].x!=-1)
            if(visina(r,p[k].x,p[k].y,x1)<mini)
                mini=visina(r,p[k].x,p[k].y,x1);
    return mini;
}
int main()
{
    int w,h,r,q,a,k=0;
    cin>>w>>h>>r>>q;
    pet p[q];
    long double u[q];
    for(int i=0;i<q;i++)
    {
        cin>>a;
        if(a==1)
        {
            cin>>p[i].x>>p[i].y;
            u[i]=-1;
        }
        else
        {
            p[i].x=-1;
            p[i].y=0;
            cin>>u[i];
        }
    }

        for(int j=0;j<q;j++)
    {
        if(u[j]!=-1)
        {
            k=j;
            cout<<fixed;
            cout<<setprecision(9)<<racunaj(h,p,k,j,u[j],r)<<" ";
        }

    }

}