#include <bits/stdc++.h>

using namespace std;
struct Krug{
    double x;
    double y;
};

Krug k[1000000];

double Visina(double x,int kN,double H,double R)
{
    double minH=H;
    for(int i=0;i<kN;i++){
        if(R*R-(x-k[i].x)*(x-k[i].x)>0){
            double H=k[i].y-sqrt(R*R-(x-k[i].x)*(x-k[i].x));
            if(H<minH)
                minH=H;
        }
    }
    return minH;
}
int main()
{
    double W,H,R;
    int Q;
    cin>>W>>H>>R>>Q;
    int kN=0;
    for(int i=0;i<Q;i++){
        int o;
        cin>>o;
        if(o==1){
            double x;
            double y;
            cin>>x>>y;
            k[kN].x=x;
            k[kN].y=y;
            kN++;
        }
        else{
            double x;
            cin>>x;
            double h=Visina(x,kN,H,R);
            cout<<setprecision(20)<<h<<endl;
        }
    }
    return 0;
}