#include <iostream>
#include <iomanip> 
#include <math.h>
#define MAX 100000
using namespace std;
int w,t;
long double h,r,lenjir[MAX];
void vertikale(long double x,long double y)
{
    long double XR=x+r;
    long double RR=r*r;
    for(int i=((x-r)>0)?(x-r):(0);i<=XR;i++)
    {
        if(RR>(i-x)*(i-x))
        {
            long double Y=y-sqrt(RR-(i-x)*(i-x));
            if(Y<lenjir[i])
                lenjir[i]=(Y>0)?(Y):(0);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>w>>h>>r>>t;
    int p=w+1;
    long double x,y;
    while(p--)
    {
        lenjir[p]=h;
    }
    while(t--)
    {
        cin>>p;
        if(p==1)
        {
            cin>>x>>y;
            vertikale(x,y);
        }
        if(p==2)
        {
            cin>>p;
            cout << fixed << setprecision(9) <<lenjir[p]<<endl;
        }
    }
    
    return 0;
}