#include <bits/stdc++.h>

using namespace std;

int w,h,r,t,que,a,b,n;
double x,y;
vector <int> krug;
vector <bool> changed;
vector <double> result;
set <pair<int,int>> krugovi;

double mini(double A, double B)
{
    if(A<B)return A;
    return B;
}

double maxi(double A, double B)
{
    if(A>B)return A;
    return B;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << showpoint;
    cout << setprecision(9);
    cin>>w>>h>>r>>t; n=w+1;
    krug.resize(w+1);
    changed.resize(w+1);
    result.resize(w+1);
    for(int i=0;i<=w;i++)
    {
        result[i] = h;
        krug[i] = h+r;
    }

    if(r==1)
    {
        while(t--){
            cin>>que;
            if(que==1){
                cin>>a>>b;
                if(b==h)result[a]=h-1;
            }else{
                cin>>a;
                cout<<result[a]<<endl;
            }
        }
        return 0;
    }
    else if(r==2)
    {
        while(t--){
            cin>>que;
            if(que==1){
                cin>>a>>b;
                result[a]=mini(result[a],b-h);
                if(a>0) result[a-1]=mini(result[a-1],b-h+0.267949192431);
                if(a<w) result[a+1]=mini(result[a+1],b-h+0.267949192431);
            }else{
                cin>>a;
                cout<<maxi(result[a],0)<<endl;
            }
        }
        return 0;
    }
    else if(t*w<=1000000)
    {
        while(true){
            cin>>que;
            if(que==1){
                cin>>a>>b;
                for(int i=max(0,a-r); i<=min(a+r,w); i++)
                {
                    result[i] = mini(result[i], b-sqrt(r*r-(i-a)*(i-a)));
                }
            }else{
                cin>>a;
                cout<<maxi(result[a],0)<<endl;
            }
        }
        return 0;
    }else{
        while(true){
            cin>>que;
            bool got=false;
            if(que==1)
            {
                got=false;
                cin>>a>>b;
                if(b < krug[a])
                {
                    krug[a]=b;
                    krugovi.insert({b,a});
                }
            }
            else
            {
                if(!got){
                    got=true;
                    //calc
                    for(auto it:krugovi){
                        b=it.first;
                        a=it.second;
                        for(int i=0;i<=r;i++)
                        {
                            x=b-sqrt(r*r-i*i);
                            if(x>=result[max(0,a-i)] && x>=result[min(a+i,w)]){
                                i=r+1;
                            }
                            else{
                                result[max(0,a-i)] = mini(result[max(0,a-i)],x);
                                result[min(a+i,w)] = mini(result[min(a+i,w)],x);
                            }
                        }
                    }

                    krugovi.clear();
                }
                cin>>a;
                cout<<maxi(result[a],0)<<endl;
            }
        }
        return 0;
    }

}