#include <bits/stdc++.h>

#define ld long double

using namespace std;

int main() {

    int w, h, r, q;
    cin >> w >> h >> r >> q;

    ld height[w + 1];
    for(int i = 0; i <= w; i++)
        height[i] = h;
    while(q--) {
        int o;
        cin >> o;

        if(o == 2) {
            int x;
            cin >> x;
            cout << height[x] << endl;
            continue;
        }

        int x, y;
        cin >> x >> y;

        if(y == h + r)
            continue;
        for(int i = max(0, x - r); i <= min(w, x + r); i++) {
            ld dx = abs(x - i), dy = y - h;
            ld diff = sqrt(r * r - dx * dx) - dy;
            if(diff <= 0)
                continue;
            height[i] = min(height[i], h - diff);
        }
    }
    return 0;
}