#include <bits/stdc++.h>
#include <vector>
#include <sstream>
using namespace std;


int main()
{
    long double merenje[100001];
    long double xstart,xstop,rkvadrat,d;
    int w,h,q,r,x,y,a,k;
    cout.precision(10);
    cin >> w >> h >> r >> q;
    long double izlaz[q+1];
    int broj_izlaza=0;
    rkvadrat=r*r;
    for (int i=0;i<=w;i++)
        merenje[i]=h;
    for (int i=0;i<q;i++)
    {
        cin >> a;
        if (a==1)
        {
            cin >> x >> y;
            d=sqrt(rkvadrat-(h-y)*(h-y));
            xstart=x-d;
            xstop=x+d;
            if(xstart<0)
                xstart=0;
            if(xstop>w)
                xstop=w;

            for (int j=ceil(xstart);j<=floor(xstop);j++)
            {
                d=y-sqrt(rkvadrat-(j-x)*(j-x));
                if (d<0)
                    d=0;
                if(d<merenje[j])
                    merenje[j]=d;
            }
        }
        else
        {
            cin >> x;
            izlaz[broj_izlaza]=merenje[x];
            broj_izlaza++;
        }
    }
    for (int i=0;i<broj_izlaza;i++)
        cout << izlaz[i] << endl;
    return 0;
}