#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
    int r,w,h,q,xi,yi,b,x,l,i,p=0;
    cin>>w>>h>>r>>q;
    double v[q];
    for(i=1;i<=q;i++)
    {
        cin>>b;
        if(b=2)
        {
            cin>>x;
            l=abs(xi-x);
            if(p=0)
                v[i]=h;
            else
            v[i]=yi-sqrt((r*r)-(l*l));
        }
        else
        {   p=1;
            cin>>xi>>yi;

        }

    }
    for(i=1;i<q;i++)
    {
        cout<<v[i]<<endl;
    }

    return 0;
}