#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 100010
lld W, H, R, Q;
struct Krug{
    lld X, Y;
    Krug() { X = INF, Y = INF; }
    Krug(lld _x, lld _y) { X = _x; Y = _y; }
    double eval(lld x) {
        if(R*R < (X-x)*(X-x)) return INF;
        return Y - sqrt(R*R - (X-x)*(X-x));
    }
};
Krug seg[4*MAXN];
bool pos[4*MAXN];
double query(int node, int l, int r, lld idx) {
    if(l == r) return seg[node].eval(idx);
    if(idx <= mid) return min(seg[node].eval(idx), query(2*node, l, mid, idx));
    return min(seg[node].eval(idx), query(2*node+1, mid+1, r, idx));
}
void update(int node, int l, int r, Krug A) {
        double aL = A.eval(l), aM = A.eval(mid), aR = A.eval(r);
        if(aL >= INF-EPS || aR >= INF-EPS) {
            if(l == r) return;
            if(aM >= INF-EPS) {
                if(A.X > mid) update(2*node+1, mid+1, r, A);
                else update(2*node, l, mid, A);
                return;
            } else {
                update(2*node, l, mid, A);
                update(2*node+1, mid+1, r, A);
                return;
            }
        }
        if(!pos[node]) {
            pos[node] = 1;
            seg[node] = A;
            return;
        }
        double sL = seg[node].eval(l), sM = seg[node].eval(mid), sR = seg[node].eval(r);
        if(sL < aL && sR < aR) return;
        if(aL < sL && aR < sR) { seg[node] = A; return; }

        if(aM < sM) swap(seg[node], A);
        if(seg[node].eval(r) > A.eval(r)) update(2*node+1, mid+1, r, A);
        else update(2*node, l, mid, A);
    }
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
    cin >> W >> H >> R >> Q;
    for(int i = 0; i < 4*MAXN; i++) seg[i] = Krug();
    while(Q--) {
        int tip; cin >> tip;
        if(tip == 1) {
            lld x, y; cin >> x >> y;
            update(1, 0, W, Krug(x, y));
        } else {
            lld x; cin >> x;
            cout << setprecision(9) << fixed << min((double)H, query(1, 0, W, x)) << endl;
        }
    }
    return 0;
}