#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int w, h, r, q, u, xi, yi;
    cin >> w >> h >> r >> q;
    vector<double> merenje(w + 1, double(h));
    double rastojanje;

    int r_na_kvadrat = r * r;

    for(int i = 0; i < q; ++i)
    {
        cin >> u;
        if(u == 1)
        {
            cin >> xi >> yi;
            int f = xi + r;
            int j = xi - r;
            for(; j <= f; ++j)
            {
                rastojanje = yi - sqrt(r_na_kvadrat - (xi - j) * (xi - j));
                if(rastojanje < merenje[j]) merenje[j] = rastojanje;
            }
        }
        else
        {
            cin >> xi;
            cout << fixed << showpoint << setprecision(15) << merenje[xi] << endl;
        }
    }

    return 0;
}