#include <bits/stdc++.h>

using namespace std;

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

    int W, H, R, Q, inL, xA, yA;

    cin>>W>>H>>R>>Q;

    int* x = new int[Q];
    int* y = new int[Q];
    long double* xL = new long double[Q];
    bool griz = false;

    for(int i = 0; i < Q; i++)
    {
        cin>>inL;
        if(inL == 1)
        {
            cin>>xA>>yA;
            xL[i] = -1;
            griz = true;
        }
        else if(inL == 2)
        {
            cin>>x[i];
            if(yA - xL[i] > H || griz == false || (R <= abs((xA - x[i])))) xL[i] = H;
            else
            {
                xL[i] = sqrt(R * R - (abs(xA - x[i])) * (abs(xA - x[i])));
                xL[i] = yA - xL[i];
            }
        }
    }

    for(int i = 0; i < Q - 1; i++)
    {
        if(xL[i] != -1) cout<<setprecision(9)<<fixed<<xL[i]<<"\n";
    }
    cout<<setprecision(9)<<fixed<<xL[Q - 1];

    delete[] x;
    delete[] y;
    delete[] xL;
    
    return 0;
}