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

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

    vector<double> dist(w+1, h); // it will be changed on every input with "1"

    for (int i = 0; i < q; ++i) {

        int d; cin >> d;

        // EAT
        if (d == 1) {
            int x, y;
            cin >> x >> y;

            for (int k = 0; k < dist.size(); ++k) {

                if (abs(x-k) < r && abs(y - h) < r) {
                    double kateta1 = abs(x - k);
                    double hip = r;
                    double kateta2 = sqrt(hip*hip - kateta1*kateta1);
                    dist[k] = y - kateta2;
                    if (dist[k] > h) dist[k] = h;
                }
            }


        } else {

            int x1; cin >> x1;
            printf("%.9f\n", dist[x1]);
            // cout << dist[x1] << setprecision(9) << endl;
        }


    }

    return 0;
}