#include <iostream>
#include<bits/stdc++.h>
using namespace std;
//vector<pair<int,int> > v;
vector<double> rez;
double oduzimanje[100001];
// ako bi svako bilo y=h za svaki griz, koliko bi duzune oduzelo susednim kolonama
int minyx[100001];

set<pair<int,int> > s;
set<pair<int,int> >::const_iterator it,it1,it2;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    double tren=0;
    int w,h,r,q,i,t,x,y,j,duz;
    cin >> w >> h >> r >> q;
    oduzimanje[0]=(double)r;
    for(i=1;i<r;i++)
        oduzimanje[i]=sqrt((double)r*(double)r-(double)i*(double)i);
    if(r>10)
    {
        for(i=0;i<q;i++)
        {
            cin >> t;
            if(t==1)
            {
                cin >> x >> y;
                if(minyx[x]==0)
                {
                    minyx[x]=y;
                    s.insert(make_pair(x,y));
                }
                else
                {
                    if(minyx[x]>y)
                    {
                        s.erase({x,minyx[x]});
                        minyx[x]=y;
                        s.insert({x,minyx[x]});
                    }
                }
            }
            else
            {
                cin >> x;
                if(s.empty()==false)
                {
                    it=s.lower_bound({x,0});
                    if(it==s.end())
                        it--;
                    tren=max(0.0,oduzimanje[abs(it->first-x)]-(it->second-(double)h));
                    if(tren<(double)h)
                    {
                        duz=upper_bound(oduzimanje,oduzimanje+r,tren)-oduzimanje;
                        it2=s.lower_bound({x+duz,0});
                        if(it2!=s.end())
                            it2++;
                        for(it1=s.lower_bound({x-duz,0});it1!=it2;it1++)
                        {
                            tren=max(tren,oduzimanje[abs(it->first-x)]-(it->second-(double)h));
                            if(tren>=(double)h)
                                break;
                        }
                    }
                    rez.push_back(max(0.0,(double)h-tren));
                }
                else
                    rez.push_back((double)h);
            }
        }
    }
    else
    {
        for(i=0;i<q;i++)
        {
            cin >> t;
            if(t==1)
            {
                cin >> x >> y;
                if(minyx[x]==0)
                    minyx[x]=y;
                else
                {
                    if(minyx[x]>y)
                        minyx[x]=y;
                }
            }
            else
            {
                cin >> x;
                tren=0.0;

                for(j=max(0,x-r+1);j<=min(x+r-1,w);j++)
                {
                    if(minyx[j]>0)
                    {
                        //printf("%.12f\n",(oduzimanje[(int)abs(j-x)]-((double)minyx[j]-(double)h)));
                        if(tren<(oduzimanje[(int)abs(j-x)]-((double)minyx[j]-(double)h)))
                        {
                            tren=oduzimanje[(int)abs(j-x)]-((double)minyx[j]-(double)h);
                            if(tren>=h)
                                break;
                        }
                    }
                }
                rez.push_back(max(0.0,(double)h-tren));
                //cout << tren << endl;
            }
        }
    }
    //for(i=0;i<r;i++)
      //  cout << oduzimanje[i] << endl;
    for(i=0;i<rez.size();i++)
        printf("%.12f\n",rez[i]);
    /*for(i=0;i<=w;i++)
    {
        if(minyx[i]>0)
            v.push_back(make_pair(i,minyx[i]));
    }*/
    //cout << "Hello world!" << endl;
    return 0;
}