#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
    int w,h;
    int r,q;


    std::cout << std::fixed;
    std::cout << std::setprecision(12);


    cin>>w>>h>>r>>q;

    double l[w],rez;
    fill(l,l+w,h);

    int c;
    int x,y;

    if(r<=2)
    {


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

                cin>>c;
                if(c==1)
                {
                    cin>>x>>y;
                    for(int j=max(0,x-2);j<=x+2;j++)
                    {
                        //cout<<"sq= "<<sqrt(r*r-j*j+2*j*x-x*x)<<" ";
                        rez=-sqrtl(r*r-j*j+2*j*x-x*x)+y;
                        //cout<<rez<<" ";
                        l[j]=min(l[j],rez);
                    }
                }
                else
                {
                    cin>>x;
                    cout<<l[x]<<"\n";
                }

            }

    }
    else
    {


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

                cin>>c;
                if(c==1)
                {
                    cin>>x>>y;
                    for(int j=0;j<=w;j++)
                    {
                        //cout<<"sq= "<<sqrt(r*r-j*j+2*j*x-x*x)<<" ";
                        rez=-sqrtl(r*r-j*j+2*j*x-x*x)+y;
                        //cout<<rez<<" ";
                        l[j]=min(l[j],rez);
                    }
                }
                else
                {
                    cin>>x;
                    cout<<l[x]<<"\n";
                }

            }



    }
    return 0;
}