#include <iostream>
#include <iomanip> 
#include <math.h>
using namespace std;
int w,t;
long double x[100000],y[100000];int br=0;
long double lenjir(long double x1)
{
    long double min=h;
    for(int i=0;i<br;i++)
    {
        if(r>(x1-x[i])||r>-(x1-x[i]))
        {
            long double Y=y[i]-sqrt(r*r-(x1-x[i])*(x1-x[i]));
            if(Y<min)
                min=Y;
        }
    }
    return (min>0)?min:0;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>w>>h>>r>>t;
    int p;
    while(t--)
    {
        cin>>p;
        if(p==1)
        {
            long double z;
            cin>>z;
            x[br]=z;
            cin>>z;
            y[br]=z;
            br++;
        }
        if(p==2)
        {
            long double X;
            cin>>X;
             cout << fixed << setprecision(12) <<lenjir(X)<<endl;
        }
    }
    
    return 0;
}