#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int k[100001];
long double n[100000];
int w,h,r;

double f(int x)
{
    long double b = h;
    long double a;
    for(int i=max(x-r,0); i<=min(x+r,w); i++)
    {
        if( k[i] != 0 )
        {
            a = k[i] - sqrt(r*r-(x-i)*(x-i));
            b = min(b, a);
        }
    }
    return b;
}

int main()
{
    ios::sync_with_stdio(false);
    int q;
    std::cout << std::setprecision(9) << std::fixed;
    cin >> w >> h >> r >> q;
    int t,x,y,j=0;
    for(int i=0; i<q; i++)
    {
        cin >> t;
        if(t==1)
        {
            cin >> x >> y;
            if(y<k[x] || k[x]==0)
                k[x]=y;
        }
        else
        {
            cin >> x;
            n[j] = f(x);
            j++;
        }
    }
    for(int i=0; i<j; i++)
    {
        cout << n[i] << endl;
    }
    return 0;
}