#include<bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

long double nizX[100010];

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

    int w, h, r, q;
    cin >> w >> h >> r >> q;
    for(int i = 0; i <= w; i++) nizX[i] = h;
    for(int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        if(a == 2)
        {
            int x;
            cin >> x;
            cout.precision(10);
            cout << fixed << nizX[x] << "\n";
        }
        if(a == 1)
        {
            int xc, yc;
            cin >> xc >> yc;

            if(r == 1)
            {
                long double y = yc*1.0 - r*1.0;
                if(y < nizX[xc]) nizX[xc] = y;
            }
            if(r == 2)
            {
                for(int i = xc -1; i <= xc + 1; i++)
                {
                    long double y = yc*1.0 - sqrt(r*r*1.0 - (xc - i)*(xc - i)*1.0);
                    if(y < nizX[i]) nizX[i] = y;
                }
            }
        }
    }


    return 0;
}