#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int w,h,q,k,c,z=0;
    long double r;
    //scanf("%d %d %d %d",&w,&h,&r,&q);
    cin >>w>>h>>r>>q;
    long double a[w+1],ispis[w+1],rastojanje,x,y;
    for (int i=0;i<=w;i++)
    {
        a[i]=h;
    }
    for (int i=0;i<q;i++)
    {
        scanf("%d",&c);
        if (c==1)
        {
            cin >>x>>y;
            //scanf("%lf %lf",&x,&y);
            for (int j=0;j<=w;j++)
            {
                rastojanje=sqrt(pow(y-a[j],2)+pow(x-j,2));
                if (rastojanje<r)
                {
                    double as=sqrt(pow(r,2)-pow(x-j,2));
                    a[j]=y-(sqrt(pow(r,2)-pow(x-j,2)));
                }
            }
        }
        else
        {
            scanf("%d",&k);
            ispis[z]=a[k];
            z++;
        }
    }
    for (int i=0;i<z;i++)
    {
        //printf("%.9Lf\n",ispis[i]);
        //cout <<ispis[i]<<endl;
        cout << std::fixed << std::setprecision(9) << ispis[i] << endl;
    }
    return 0;
}