#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> koord;
vector<long double> Tetive (1000002);

int merenjeX=0;
int r;
map<int,int> krugovi;
inline bool cmp(koord k1,koord k2)
{
    long double d1 = abs(merenjeX-k1.first);
    long double d2 = abs(merenjeX-k2.first);
    long double dy = k1.second-k2.second;
    if(k1.second>k2.second){
        long double a=d2*d2-d1*d1-dy*dy;
        long double b = 2*dy;
        return a*a<b*b*(r*r-d2*d2);
    }
    long double a=d1*d1-d2*d2-dy*dy;
    long double b = 2*dy;
    return a*a<b*b*(r*r-d1*d1);

}

void pronadjiTetive(int r)
{
    for(int i=0;i<r;i++){ Tetive[i]=sqrt((long double)r*r-i*i);}
}

int main()
{
    ios_base::sync_with_stdio(false);
    std::cout << std::fixed;
    std::cout << std::setprecision(9);
    int h,w,q;
    cin>> w>>h>>r>>q;
    pronadjiTetive(r);
    for(int i=0;i<q;i++){
        int zad,xi,yi;
        cin>> zad;
        if(zad==1){
            cin>>xi>>yi;
            auto nadjen=krugovi.find(xi);
            if(nadjen!=krugovi.end())
                krugovi[xi]=min(krugovi[xi],yi);
            else
                krugovi[xi]=yi;
        }
        else{
            cin>>merenjeX;
            auto nadjen = max_element(krugovi.lower_bound(xi-r+1),krugovi.upper_bound(xi+r),cmp);
            if(nadjen!=krugovi.end())
                cout<< max((long double)0.0,min((long double)h,(long double)nadjen->second-Tetive[abs(merenjeX-nadjen->first)]))<<endl;
            else
                cout<<(double) h<<endl;
        }
    }


    return 0;
}