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

int w,h;
long double R[100001];
long double Keks[100001];

int Zagrizi( int x, int y, int r )
{
    long double kraj = x - sqrt( abs(r*r-(y-h)*(y-h)) ), pocetak = x + sqrt( abs(r*r-(y-h)*(y-h)) );
    int i = pocetak;
    long double vrednost;

    for ( i = pocetak; i > kraj; i-- )
    {
        if ( i <= w && i >= 0 )
        {
            vrednost = y-sqrt( abs(r*r - (i-x)*(i-x)) );
            if ( vrednost < Keks[i] )
            {
                Keks[i] = vrednost;
            }
        }
    }
}

int main()
{
    int r,q,p,x,y;
    int ir = 0;

    cin >> w >> h >> r >> q;
    for ( int g = 0; g <= w; g++ )
    {
        Keks[g] = h;
    }
    for ( int g = 0; g < q; g++ )
    {
        cin >> p;
        if ( p == 1 )
        {
            cin >> x >> y;
            Zagrizi( x, y, r );
        }
        else
        {
            cin >> x;
            R[ir++] = Keks[x];
        }
    }

    ir--;
    for ( int i = 0; i <= ir; i++ )
    {
        std::cout << std::setprecision(9);
        cout << R[i] << endl;
    }

    return 0;
}