#include <bits/stdc++.h>
using namespace std;
int w,h,r,q,x,y,b;
double a[100005],z,p;
int main () {
scanf("%d%d%d%d",&w,&h,&r,&q);
for (int i=0;i<=w;i++){
    a[i]=h;
}
for (int i=1;i<=q;i++){
    scanf("%d",&b);
    if (b==1){
       scanf("%d%d",&x,&y);
       a[x]=min(y-r*1.0,a[x]);
      for (int j=1;j<=r-1;j++){
        z=sqrt(r*r-j*j);
        p=y-z;
        if (x-j>=0){
           a[x-j]=min(p,a[x-j]);
        }
        if (x+j<=w){
            a[x+j]=min(p,a[x+j]);
        }
      }

    }
    else {
        scanf("%d",&x);
        cout<<setprecision(10)<<fixed;
        cout<<a[x]<<endl;
    }
}
return 0;
}