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


int main ()
{
    int W,H,R,Q;
    cin >> W >> H >> R >> Q; //sirina, visina, poluprecnik kruga, broj komandi
    int f[Q];
    int xc[Q];
    int yc[Q];
    int xm[Q];
    long double merenje[Q]={H};
    for (int i=0; i<Q; i++)
    {
        cin >> f[i];
        if (f[i]==1) //GRIZE
        {
            cin >> xc[i] >> yc[i];
        }
        if (f[i]==2) //MERIMO
        {
            cin >> xm[i];

            long double minDuzina=H;
            for (int j=0; j<i; j++)
            {
                if (f[j]==1) //ako je komanda griz
                {
                    long double mera=H;
                    if (xm[i]>(xc[j]-R) && xm[i]<(xc[j]+R))
                    {
                       mera = yc[j]-sqrt(pow (R,2) - pow (abs(xc[j]-xm[i]),2));
                    }
                    if (mera<minDuzina)
                    {
                        minDuzina = mera;
                    }
                }
            }
            merenje[i]=minDuzina;
        }
    }

    for (int i=0; i<Q; i++)
    {
        if (f[i]==2)
        {
            cout << setprecision(11) << merenje[i] << fixed << "\n" ;
        }
    }
    return 0;
}