#include <bits/stdc++.h>

using namespace std;
int w, h, r, q, ind, xi, yi;
double f(double x){
    double y;
    y=yi-sqrt(r*r-(x-xi)*(x-xi));
    return y;
}
int main()
{
    ios::sync_with_stdio(false);
   // cin.tie(NULL); cout.tie(NULL);
    cin>>w>>h>>r>>q;
    vector<double> a(w+1, double(h));

    while(q--){

        cin>>ind;

        if(ind==1){
            cin>>xi>>yi;
            for(int x=max(0, xi-r); x<=min(w, xi+r); x++){
                a[x]=min(a[x], f(double(x)));
            }
        }
        else if(ind==2){
            cin>>xi;
           // cout<<a[xi]<<endl;
            printf("%.12f\n", a[xi]);
        }
    }
    return 0;
}