#include <iostream>
#include<cmath>
#include <iomanip>

using namespace std;

int x;
int w,h,r,q;
int zalogaji[100003][2];
int zCount = 0;
int oCount = 0;
int order;
double out[100003];

int main()
{
    std::ios::sync_with_stdio(false);

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

    std::cout << std::setprecision(13);

    for(int i = 0;i < q;i++){
        cin >> order;
        if(order == 1){
            cin >> zalogaji[zCount][0] >> zalogaji[zCount][1];
            zCount++;
        }else{
            cin >> x;

            if(zCount > 0){
                double m = (double)zalogaji[0][1] - sqrt((double)r*r - pow((double)(x - zalogaji[0][0]),2));
                for(int i = 1;i < zCount;i++){
                    double t = (double)zalogaji[i][1] - sqrt((double)r*r - pow((double)(x - zalogaji[i][0]),2));
                    if(t < m)
                        m = t;
                }
                if(m > h)
                    m = h;

                if(m < 0)
        			m = 0;

                out[oCount] = m;
            }else
                out[oCount] = h;
            oCount++;
        }
    }

    for(int i = 0;i < oCount;i++){
        cout << out[i] << endl;
    }

    return 0;
}