#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int w,h,r,q;
double he[100005];

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;
    
    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],(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],(double)y-r);
                double yy = y - sqrt((double)r*r - 1);
                if(x-1 >= 0) he[x-1] = min(he[x-1],yy);
                he[x+1] = min(he[x+1],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],yy);
                   if(x+i <= w) he[x+i] = min(he[x+i],yy);
                }
            }
        }
    }
    
    
    return 0;
}