#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    int w,h,r,q,nkrug=0,nprava=0;
    cin>>w>>h>>r>>q;
    long double krug[q][2],prava[q];
    for(int i=0;i<q;i++)
    {
        int broj;
        cin>>broj;
        if(broj==1)
        {
            cin>>krug[nkrug][0]>>krug[nkrug][1];
            nkrug++;
        }
        else
        {
            cin>>prava[nprava];
            nprava++;
        }
    }
    for(int i=0;i<nprava;i++)
    {
        long double y=(long double)h,rr=(long double)r;
        for(int j=0;j<nkrug;j++)
        {
            if(rr*rr>=(prava[i]-krug[j][0])*(prava[i]-krug[j][0]))
            {
                long double yy=krug[j][1]-sqrt(rr*rr-(prava[i]-krug[j][0])*(prava[i]-krug[j][0]));
                if(yy<y)
                    y=yy;
            }
        }
        cout<<setprecision(10)<<y<<endl;
    }
    return 0;
}