#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int H,W,Q,R,tip,x,y;
long double niz[100005];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cout<<fixed<<setprecision(12);
    cin>>W>>H>>R>>Q;
    for(int i=0;i<=W;i++)
        niz[i]=H;
    if(R==1){
        while(Q--){
            cin>>tip;
            if(tip==1){
                cin>>x>>y;
                if(y==H)
                    niz[x]=H-1;
            }
            else {
                cin>>x;
                cout<<niz[x]<<endl;
            }
        }
    }
    if(R==2){
        while(Q--){
            cin>>tip;
            if(tip==1){
                cin>>x>>y;
                niz[x]=min(niz[x],(ld)y-2);
                niz[x+1]=min(niz[x+1],(ld)y-sqrt(R*R-1));
               if(x!=0) niz[x-1]=min(niz[x-1],(ld)y-sqrt(R*R-1));
            }
            else {
                cin>>x;
                cout<<niz[x]<<endl;
            }
        }
    }
    return 0;
}