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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int w,h,q,r,dog,x,l,d,rast,xk;
    double h2,rez,y;
    cin >> w >> h2 >> r >> q;
    //double h1=(double)h;
    vector<double>v(w+1,h2);
    for (int i=0;i<q;i++)
    {
        cin >> dog;
        if (dog==1)
        {
            cin >> x >> y;
            l=max(x-r+1,0);
            d=min(x+r-1,w);
            for (int j=l;j<=d;j++)
                {
                    rast=abs(x-j);
                    double RR=sqrt(r*r-rast*rast);
                    rez=y-RR;
                    v[j]=min(v[j],rez);
                }
        }
        else if (dog==2)
        {
            cin >> xk;
            cout << fixed << showpoint << setprecision(10) << v[xk] << '\n';
        }
    }
}