#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int w,h,r,q;
double he[100005];
int mpx[100005];
set<int> sx;
set<int> syx;
int ymi;
vector<pair<int,int>> v;
vector<int> vx;
vector<int> vy;
int seg[500005];
vector<int> yx[100005];

void build(int id,int l,int r)
{
    if(l==r)
    {
        seg[id] = l;
    }
    else
    {
        int mid = (l+r)/2;
        build(2*id,l,mid);
        build(2*id+1,mid+1,r);
        
        if(vy[seg[2*id]] < vy[seg[2*id+1]]) seg[id] = seg[2*id];
        else  seg[id] = seg[2*id+1];
    }
}

int mini(int id,int l,int r,int xl,int xr)
{
    if(xr < l || r < xl) return -1;
    if(xl<=l && r<=xr) return seg[id];
    
    int mid = (l+r)/2;
    int p1 = mini(2*id,l,mid,xl,xr);
    int p2 = mini(2*id+1,mid+1,r,xl,xr);
    
    if(p1==-1) return p2;
    if(p2==-1) return p1;
    
    if(vy[p1] < vy[p2]) return p1;
    else  return p2;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    
    cout << fixed << showpoint;
    cout << setprecision(12);
    
    cin >> w >> h >> r >> q;
    
    for(int i=0;i<=w;i++) he[i] = (double)h;
    for(int i=0;i<=w;i++) mpx[i] = h+r+2;
    
    if(r==1)
    {
        while(q--)
        {
            int nar;
            cin >> nar;
            if(nar==2)
            {
                int x;
                cin >> x;
                cout << he[x] << "\n";
            }
            else
            {
                int x,y;
                cin >> x >> y;
                he[x] = min(he[x],max(0.0,(double)y-r));  
            }
        }
    }
    else if(r==2)
    {
        while(q--)
        {
            int nar;
            cin >> nar;
            if(nar==2)
            {
                int x;
                cin >> x;
                if(he[x] < 0.0) cout << 0;
                else cout << he[x] << "\n";
            }
            else
            {
                int x,y;
                cin >> x >> y;
                he[x] = min((double)he[x],max(0.0,(double)y-r));
                double yy = y - sqrt((double)r*r - 1);
                if(x-1 >= 0) he[x-1] = min(he[x-1],max(yy,0.0));
                he[x+1] = min(he[x+1],max(0.0,yy));
            }
        }
    }
    else if((ll)q*w<=1000000)
    {
        while(q--)
        {
            int nar;
            cin >> nar;
            if(nar==2)
            {
                int x;
                cin >> x;
                if(he[x] < 0.0) cout << 0;
                else cout << he[x] << "\n";
            }
            else
            {
                int x,y;
                cin >> x >> y;
                he[x] = min((double)he[x],(double)y-r);
                for(int i=1;i<r && (x+i <= w || x-i>=0);i++)
                {
                   double yy = y - sqrt((double)r*r - i*i);
                   if(yy > (double)h) break;
                   if(x-i>=0) he[x-i] = min(he[x-i],max(0.0,yy));
                   if(x+i <= w) he[x+i] = min(he[x+i],max(0.0,yy));
                }
            }
        }
    }
    else
    {
        bool so = false;
        while(q--)
        {
            int nar;
            cin >> nar;
            if(nar==1)
            {
                int x,y;
                cin >> x >> y;
                if(y==h+r) continue;
                v.push_back({x,y});
                mpx[x] = min(y,mpx[x]);
            }
            else
            {
                if(!so)
                {
                    so=true;
                    sort(v.begin(),v.end());
                    for(auto pa : v)
                    {
                      vx.push_back(pa.first);
                      vy.push_back(pa.second);
                      yx[pa.second].push_back(pa.first);
                    }
                    build(1,0,vy.size()-1);
                }
                int x;
                cin >> x;
                if(v.size()==0)
                {
                    cout << he[x] << "\n";
                    continue;
                }
                
                //po x
                vector<int>::iterator it;
                it = lower_bound(vx.begin(),vx.end(),x);
                double sol = 1000000000.0;
                if(it==vx.end())
                {
                    it--;
                    if(*it > x-r)
                    {
                        int yt = mpx[*it];
                        int rr = abs(*it-x);
                       // cout << sol << "\n";
                        sol = min(sol,(double)yt - sqrt((double)r*r - rr*rr));
                    }
                }
                else if(*it==x)
                {
                    //cout << sol << "\n";
                    int yt = mpx[x];
                    sol = min(sol,(double)yt - r);
                }
                else
                {
                    int x1 = *it;
                    if(it!=vx.begin()) it--;
                    int x2 = *it;
                    int r1 = abs(x-x1);
                    int r2 = abs(x-x2);
                    if(r1 < r2)
                    {
                        int yt = mpx[x1];
                        sol = min(sol,(double)yt - sqrt((double)r*r - r1*r1));
                    }
                    else if(r1 > r2)
                    {
                        int yt = mpx[x2];
                        sol = min(sol,(double)yt - sqrt((double)r*r - r2*r2));
                    }
                    else
                    {
                        int yt = min(mpx[x1],mpx[x2]);
                        sol = min(sol,(double)yt - sqrt((double)r*r - r1*r1));
                    }
                   // cout << sol << "\n";
                }
                he[x] = min(max(sol,0.0),he[x]);
                
                //po y
                int x1 = max(0,x-r+1);
                int x2 = min(w,x+r-1);
                vector<int>::iterator it1;
                vector<int>::iterator it2;
                it1 = lower_bound(vx.begin(),vx.end(),x1);
                if(it1!=vx.end())
                {
                    it2 = lower_bound(vx.begin(),vx.end(),x2);
                    if(it2==vx.end() || *it2 > x2) it2--;
                    int i1 = it1 - vx.begin();
                    int i2 = it2 - vx.begin();
                    if(i1 < i2)
                    {
                     
                        int ind = mini(1,0,vy.size()-1,i1,i2);
                    
                        //cout << ind << "\n";
                    
                        int yt = vy[ind];
                        //cout << yt << "\n";
                        it1 = lower_bound(yx[yt].begin(),yx[yt].end(),x);
                        if(it1==yx[yt].end()) 
                        {
                            it1--;
                            x1 = *it1;
                            x2=*it1;
                        }
                        else
                        {
                            x1 = *it1;
                            it1--;
                            x2=*it1;
                        }
                        //cout << x1 << " " << x2 << "\n";
                        int rr = min(abs(x-x1),abs(x-x2));
                    
                       // cout << "po y " << vy[ind] << " " << rr << "\n"; 
                    
                        sol = min(sol,(double)vy[ind] - sqrt((double)r*r - rr*rr));
                        //cout << sol << "\n";
                        he[x] = min(he[x],max(sol,0.0));
                    }
                }
                
                cout << he[x] << "\n";
                //cout << "\n";
                
            }
        }
    }
    
    return 0;
}