#include<iostream>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;
int main ()
{
    int w,h,r,q,x1,y1,b,x,i;
    double k;
    cin>>w>>h>>r>>q;
    vector <double> v;
    for(i=0;i<q;i++)
    {cin>>b;
    if(b==1)
    {
        cin>>x1>>y1;
    }
    else
    {
        if(b==2)
        {
            cin>>x;
            if(x<=(x1-r))
            v.push_back(h);
            else
            {
                k=sqrt((r*r)-((x1-x)*(x1-x)));
                if((y1-k)>h) v.push_back(h);
                else v.push_back(y1-k);
            }
        }
    }


    }
    for(i=0;i<v.size();i++)
    cout<<fixed<<setprecision(12)<<v[i]<<endl;

    return 0;
}