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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e5+5;

int w,h,r,q;
double a[N];

void solve1(){
    for(int i=0;i<=w;i++)a[i]=(double)h;
    while(q--){
        int t,x,y;
        cin>>t>>x;
        if(t==1){
            cin>>y;
            if(y==h){
                a[x]=min(a[x],h-1.0);
            }
        }else{
            cout<<fixed<<setprecision(12)<<a[x]<<"\n";
        }
    }
}

void solve2(){
    for(int i=0;i<=w;i++)a[i]=(double)h;
    while(q--){
        int t,x,y;
        cin>>t>>x;
        if(t==1){
            cin>>y;
            if(y==h+1){
                a[x]=min(a[x],h-1.0);
                double q=(double)y-sqrt((double)r*r-(double)(x-1-x)*(x-1-x));
                if(x>=1)a[x-1]=min(a[x-1],q);
                a[x+1]=min(a[x+1],q);
            }else if(y==h){
                a[x]=min(a[x],h-2.0);
                double q=(double)y-sqrt((double)r*r-(double)(x-1-x)*(x-1-x));
                if(x>=1)a[x-1]=min(a[x-1],q);
                a[x+1]=min(a[x+1],q);
            }
        }else{
            cout<<fixed<<setprecision(12)<<a[x]<<"\n";
        }
    }
}

void solve3(){
    for(int i=0;i<=w;i++)a[i]=(double)h;
    while(q--){
        int t,x,y;
        cin>>t>>x;

        if(t==1){
            cin>>y;
            for(int i=max(0,x-r);i<=min(w,x+r);i++){
                double q=(double)y-sqrt((double)r*r-(double)(i-x)*(i-x));
                a[i]=min(a[i],q);
            }
        }else{
            cout<<fixed<<setprecision(12)<<a[x]<<"\n";
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>w>>h>>r>>q;

    if(r==1)solve1();
    else if(r==2)solve2();
    else if(1LL*q*w<=1000000LL)solve3();
    else solve3();

    return 0;
}