#include<bits/stdc++.h>
using namespace std;
int W,H,R,Q,xi,yi,u,br=0;
vector<double> resenja;
int main()
{
    scanf("%d %d %d %d",&W,&H,&R,&Q);
    double out[W];
    for(int i=0;i<W;i++)
    out[i]=H;
    for(int i=0;i<Q;i++)
    {
        scanf("%d %d",&u,&xi);
        if(u==1)
        {
            scanf("%d",&yi);
            for(int j=0;j<W;j++)
            {
                if(R*R-(out[j]-xi)*(out[j]-xi)>0)
                out[j]=(out[j]<yi-sqrt(R*R-(out[j]-xi)*(out[j]-xi))? out[j]:yi-sqrt(R*R-(out[j]-xi)*(out[j]-xi);
            }
        }else {resenja.push_back(out[xi]);br++;}
    }
    for(int i=0;i<br;i++)
    cout<<resenja[i]<<endl;
    return 0;
}