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

#define ld (long double)
int main()
{
    long long w,h,r,q,ind,x,y;
    cin>>w>>h>>r>>q;
    long double a[w+1];
    for(int i=0; i<=w; ++i) a[i]=h;
    long double l,p;
    while(q--) {
        cin>>ind;
        if(ind==1) {
            cin>>x>>y;
            long double l;
            for(long long i=x; i>=0 && (x-i)<=r;--i) {
                l=sqrt(ld r*ld r-(ld x-ld i)*(ld x- ld i));
                p=y-l;
                if(p>=h) break;
                a[i]=min(a[i],p);
            }
            for(long long i=x+1; i<=w && (i-x)<=r;++i) {
                l=sqrt(ld r*ld r-(ld x-ld i)*(ld x- ld i));
                p=y-l;
                if(p>=h) break;
                a[i]=min(a[i],p);
            }
        }
        else {
            cin>>x;
            printf("%.10llf\n",a[x]);
        }
    }
    return 0;
}