#include <bits/stdc++.h>
#include <iomanip>
///https://cp-algorithms.com/geometry/convex_hull_trick.html
using namespace std;
int w,h,Radius,q;

typedef int ftype;
//typedef complex<ftype> point;
struct point{
int x,y;
};

const int maxn = 100000;
point line[4 * maxn];
int sqr(int x1){
return x1*x1;
}
const int inf = 1000000000;
double f(point a,  ftype xx) {
    ///a(x)
    if(sqr(Radius)-sqr(a.x-xx)<0||a.x==a.y&&a.x==0)return inf;
    return (double)a.y-sqrt(sqr(Radius)-sqr(a.x-xx));
}

double get(int x, int v = 1, int l = 0, int r = maxn) {
    int m = (l + r) / 2;
    if(r - l == 1) {
        return f(line[v], x);
    } else if(x < m) {
        return min(f(line[v], x), get(x, 2 * v, l, m));
    } else {
        return min(f(line[v], x), get(x, 2 * v + 1, m, r));
    }
}



void add_line(point nw, int v = 1, int l = 0, int r = maxn) {
   // cout <<"IN PROCESS"<<endl;
     int m = (l + r) / 2;
    /*if(nw.x+Radius<l||nw.x-Radius>r){
    return;
    }
    if(!(nw.x-Radius<=l&&nw.x+Radius>=r)){
      add_line(nw, 2 * v, l, m);
      add_line(nw, 2 * v + 1, m, r);
      return;
    }*/

    bool lef = f(nw, l) < f(line[v], l);
    bool mid = f(nw, m) < f(line[v], m);
    if(mid) {
        swap(line[v], nw);
    }
    if(r - l == 1) {
        return;
    } else if(lef != mid) {
        add_line(nw, 2 * v, l, m);
    } else {
        add_line(nw, 2 * v + 1, m, r);
    }
}

double Upit(int x1){
    return get(x1);
}
void Dodaj(int x1,int y1){
    point p;
    p.x=x1;
    p.y=y1;
    //p.r=Radius, ofc
    add_line(p);
}

int main(){
    ios_base::sync_with_stdio(false);

    cin.tie(0);
    cout.tie(0);
    cin >>w>>h>>Radius>>q;
    std::cout << std::fixed;
    for(int i=0;i<q;i++){
        int t;
        cin >>t;
        if(t==1){
            int x1,y1;
            cin >>x1>>y1;
            Dodaj(x1,y1);
        }
        else{
            int x1;
            cin >>x1;
            cout <<setprecision(9)<<max(0.0,min(Upit(x1),(double)h))<<endl;
        }
    }
}