#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
double izracunajVisinu(long double x,long double y,long double r,long double b,long double h) // popraviti funkciju navodno ne vraca nista (moguca greska u mesanju doublea sa intom)
{
    long double pom;
    if (b==x)
    {
        pom=h-(abs(r-(y-h)));
        return pom;
    }
    else
    {
        double p1,p2,p3;

        if (b<x)
        {

            if(x-r<b)
            {
                p1=r*r;
                p2=(x*x)-2*(x*b)+(b*b);
                p3=sqrt(p1-p2);
                pom=y-p3;
                return pom;
            }
            else
            {
                return h;
            }

        }

        else
        {

            b=x-(b-x);
            p1=r*r;
            p2=(x*x)-2*(x*b)+(b*b);
            p3=sqrt(p1-p2);
            pom=y-p3;
            return pom;
        }

    }
}
int main()
{
    long long w,h,r,q,pom;
    cin>>w>>h>>r>>q;
    int x[q],y[q],trazenaVisina[q],dolazakDecaka[q],g=0,l=0;
    long double resenja[q],visina[w+1];
    for (int i=0; i<=w; i++)
    {
        visina[i]=h;
    }

    for (int i=0; i<q; i++)
    {
        cin>>pom;
        if (pom==1)
        {
            g++;
            cin>>x[g]>>y[g];
        }

        else
        {
            cin>>trazenaVisina[l];
            dolazakDecaka [l]=g;

            l++;
        }


    }
    pom=0;
    while (dolazakDecaka[pom]==0)
    {
        resenja[pom]=h;
        pom++;
    }
    for (int i=1; i<g+1; i++)
    {
        for (int j=0; j<=w; j++)
        {


            if (izracunajVisinu(x[i],y[i],r,j,h)<visina[j])
                visina[j]=izracunajVisinu(x[i],y[i],r,j,h);
            if (dolazakDecaka[j]==i)
            {
                resenja[pom]=visina[trazenaVisina[pom]];
                pom++;
            }

        }
    }

    for(int i=0; i<l; i++)
    {

        std::cout << setprecision(12) << fixed;
        cout<<resenja[i]<<endl;
    }

    return 0;

}