#include <bits/stdc++.h>
using namespace std;

vector<vector<double> > kor;
int main() {
    kor.resize(2);
    int w,q,num;
    double a,b,res,r,h,x;
    scanf("%d %lf %lf %d",&w,&h,&r,&q);
    for (int i=0; i<q; i++) {
        scanf(" %d",&num);
        if (num==1) {
            scanf(" %lf %lf",&a,&b);
            kor[0].push_back(a);
            kor[1].push_back(b);
        }
        else {
            scanf(" %lf",&a);
            res=h;
            for (int k=0; k<kor[0].size();k++) {
                if (r*r>=(a-kor[0][k])*(a-kor[0][k])) {
                    x=-sqrt(r*r-(a-kor[0][k])*(a-kor[0][k]))+kor[1][k];
                    if (x<res) {
                        res=x;
                    }
                }
            }
            printf("%.12lf\n",res);
        }
    }
}