#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int w,h,r,q,nkrug=0,nprava=0;
    cin>>w>>h>>r>>q;
    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++)
    {
        double y=(double)h,rr=(double)r;
        for(int j=0;j<nkrug;j++)
        {
            if(rr>=prava[i]-krug[j][0])
            {
                double yy=krug[j][1]-sqrt(rr*rr-(prava[i]-krug[j][0])*(prava[i]-krug[j][0]));
                if(yy<y)
                    y=yy;
            }
        }
        cout<<y<<endl;
    }
    return 0;
}