#include <bits/stdc++.h>

using namespace std;

int main()
{
    int w,h,r,q, num, x, y;
    cin >> w >> h >> r >> q;
    vector<double> sol;
    double niz[w];
    for(int i=0;i<w;i++)niz[i] = double(h);
    for(int i=0;i<q;i++)
    {
        cin >> num;
        if(num==1)
        {
           cin >> x >> y;
           for(int i=max(0, x-r);i<min(w, x+r);i++)
           {
               niz[i] = min((double)y - sqrt(double(r*r) - double(x-i)*(x-i)), niz[i]);
           }
        }
        else
        {
            cin >> x;
            sol.push_back(niz[x]);
        }
    }
    for(auto x : sol)cout << setprecision(13) << x << endl;
    return 0;
}