#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[100005];
int ymi;
int seg[1000005];

void update(int id,int l,int r,int idx,int val)
{
    if(l==r)
    {
        mpx[idx] = min(mpx[idx],val);
        seg[id] = min(seg[id],val);
    }
    else
    {
        int mid = (l+r)/2;
        if(l<=idx && idx<=mid) update(2*id,l,mid,idx,val);
        else update(2*id+1,mid+1,r,idx,val);

        seg[id] = min(seg[2*id],seg[2*id+1]);
    }
}

int mini(int id,int l,int r,int xl,int xr)
{
    if(xr < l || r < xl) return h+r+2;
    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);

    return min(p1,p2);
}

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

       seg[id]=min(seg[2*id],seg[2*id+1]);
   }
}

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;
    build(1,0,w);

    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;
                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;
                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
    {
        while(q--)
        {
            int nar;
            cin >> nar;
            if(nar==1)
            {
                int x,y;
                cin >> x >> y;
                if(y==h+r) continue;
                sx.insert(x);
                syx[y].insert(x);
                update(1,0,w,x,y);
            }
            else
            {
                int x;
                cin >> x;
                int xl = max(x-r+1,0);
                int xr = min(w,x+r-1);
                double sol = 1000000000.00;
                int vr = mini(1,0,w,xl,xr);
                if(vr==h+r+2)
                {
                    cout << he[x] << "\n";
                    continue;
                }
                set<int>::iterator it;
                int x1;
                int x2;
                it = syx[vr].lower_bound(x);
                if(it==syx[vr].end())
                {
                    it--;
                    x1=*it;
                    x2=*it;
                }
                else
                {
                    x1=*it;
                    if(it!=syx[vr].begin()) it--;
                    x2=*it;
                }
                int r1 = abs(x-x1);
                int r2 = abs(x-x2);
                if(r1 < r2)
                    sol = min(sol,(double)vr - sqrt((double)r*r - r1*r1));
                else if(r1 > r2)
                    sol = min(sol,(double)vr - sqrt((double)r*r - r2*r2));
                else
                    sol = min(sol,(double)vr - sqrt((double)r*r - r1*r1));

                 he[x] = min(max(0.0,sol),he[x]);


                //po x
                it = sx.lower_bound(x);
                if(it==sx.end())
                {
                    it--;
                    if(*it > x-r)
                    {
                        int yt = mpx[*it];
                        int rr = abs(*it-x);
                        sol = min(sol,(double)yt - sqrt((double)r*r - rr*rr));
                    }
                }
                else if(*it==x)
                {
                    int yt = mpx[x];
                    sol = min(sol,(double)yt - r);
                }
                else
                {
                    int x1 = *it;
                    if(it!=sx.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));
                    }
                }
                he[x] = min(max(sol,0.0),he[x]);

                cout << he[x] << "\n";

            }
        }

    }

    return 0;
}