#include <bits/stdc++.h>
using namespace std;

struct paar
{
    long double dole, gore;
};

vector<paar> opsezi;
vector<long double> rez;
int main()
{
    int w, h, r, q;
    cin >> w >> h >> r >> q;

    for (int i = 0; i <= w; i++)
    {
        paar p;
        p.dole = (long double)INT_MAX;
        p. gore = (long double)INT_MIN;
        opsezi.push_back(p);
    }

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

        if (k == 1)
        {
            int a, b;
            cin >> a >> b;

            for (int j = a-r; j <= a+r; j++)
            {
                if (j >=0 && j <= w)
                {
                    opsezi[j].dole = min(opsezi[j].dole, (long double)(b-sqrt(r*r-(a-j)*(a-j))));
                    opsezi[j].gore = max(opsezi[j].gore, (long double)(b+sqrt(r*r-(a-j)*(a-j))));
                }
            }
        }
        else if (k == 2)
        {
            int a;
            cin >> a;

            if (opsezi[a].gore > 0 && opsezi[a].dole <= 0)
            {
                rez.push_back(0.0);
            }
            else
            {
                rez.push_back(min(opsezi[a].dole, (long double)h));
            }
        }
    }

    for (int i = 0; i < (int)rez.size(); i++)
    {
        cout << setprecision(15) << rez[i] << endl;
    }

    return 0;
}