#include <iostream>
#include <cmath>
using namespace std;

int main ()
{

    long W, H, R, Q;
    cin >> W >> H >> R >> Q;

    long double M[W+1];
    for (long i=0; i<=W; i++)
        M[i] = (long double)H;

    int t; long x, y;

    for (long i=0; i<Q; i++)
    {
        cin >> t;
        if (t==1)
        {
            cin >> x >> y;

            if (M[x]>(long double)(y-R))
                M[x] = (long double)(y-R);

            for (long i = 1; (i<R && x+i<=W); i++)
                if ( M[x+i] > (long double)y - sqrt( (long double)(R)*(long double)(R)-(long double)(i)*(long double)(i) ) )
                    M[x+i] = (long double)y - sqrt( (long double)(R)*(long double)(R)-(long double)(i)*(long double)(i) );

            for (long i = 1; (i<R && x-i>=0); i++)
                if ( M[x-i] > (long double)y - sqrt( (long double)(R)*(long double)(R)-(long double)(i)*(long double)(i) ) )
                    M[x-i] = (long double)y - sqrt( (long double)(R)*(long double)(R)-(long double)(i)*(long double)(i) );
        }
        else
        {
            cin >> x;
            cout.precision(12);
            cout << M[x];
        }
    }

    return 0;
}