#include <bits/stdc++.h>
using namespace std;
int w,h,r,q,x,y,b;
double a[10000005],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);
      for (int j=0;j<=w;j++){
        z=sqrt(r*r-abs(x-j)*abs(x-j));
        p=y-z;
           a[j]=min(p,a[x-j]);
      }
    }
    else {
        scanf("%d",&x);
        cout<<setprecision(10)<<fixed;
        cout<<a[x]<<endl;
    }
}
return 0;
}