#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si short int
#define vi vector<ll>
#define vii vector<vi>
vector<pair<double,double>> krugovi;
double w,h,r;

double dist(double x, pair<double,double> krug)
{
    double z=abs(krug.first-x);
    double t=sqrt(r*r-z*z);
    return abs(krug.second-t);
}

double izracunaj(double x)
{
    double y=DBL_MAX;
    if(krugovi.size()==0) return h;
    for(ll i=0;i<krugovi.size();i++)
    {
        if(x>=krugovi[i].first-r)
        {
            double pom=dist(x,krugovi[i]);
            if(h<=pom)
                y=min(y,h);
            else
                y=min(pom,y);
        }
    }
    return y;
}

int main(void)
{
    ll q;
    cin>>w>>h>>r>>q;

    while(q--)
    {
        si n;
        cin>>n;
        if(n==1)
        {
            double x,y;
            cin>>x>>y;
            krugovi.push_back({x,y});
        }
        else if(n==2)
        {
            double x;
            cin>>x;
            printf("%.9lf\n", izracunaj(x));
        }
    }
}