#include <bits/stdc++.h>

using namespace std;

int main()
{
    double r, q, a, y, h;
    int w, x;

    cin >> w >> h >> r >> q;

    double visina[w+1];
    //memset(visina, h, sizeof(visina));

    for(int i=0; i < w+1; i++)
    {
        visina[i] = h;
    }

    cout << setprecision(12) << fixed;

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

        if(a == 1)
        {
            cin >> x >> y;
            visina[x] = min(h, (y-r));

            for(int i=1; i <= x; i++)
            {
                if(h > y-sqrt(r*r - i*i))
                {
                    visina[x-i] = y-sqrt(r*r - i*i);
                }
                else
                {
                    break;
                }

            }

            for(int i=1; i <= w-x; i++)
            {
                if(h > y-sqrt(r*r - i*i))
                {
                    visina[x+i] = y-sqrt(r*r - i*i);
                }
                else
                {
                    break;
                }

            }
        }
        else if(a == 2)
        {
            cin >> x;

            cout << visina[x] << endl;
        }
    }
    return 0;
}