#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main()
{
    long W,H,Q;
    long R;
    scanf("%ld %ld %ld %ld",&W, &H, &R, &Q);
    long double* visine = (long double*) malloc(sizeof(long double) * (W + 1));
    long double* max = (long double*) malloc(sizeof(long double) * (W + 1));
    long double* min = (long double*) malloc(sizeof(long double) * (W + 1));
    long Ai;
    long x,y;
    for(long i = 0; i < W; i++)
    {
        visine[i] = H;
        max[i] = H;
        min[i] = H;
    }
    int izbor;
    for(long i = 0; i < Q; i++)
    {
        scanf("%d",&izbor);
        if(izbor == 1)
        {
            scanf("%ld%ld",&x,&y);
            long double y1 = y;
            long nes =  (x + R) + 1;
            for(long i = (long)(x - R) - 1; i <= nes; i++)
            {
                if(i >= 0 && i <= W)
                {
                    if(i == x)
                    {
                        long double nova = y1 - R;
                        min[i] = (min[i] < nova) ? min[i] : nova;
                        visine[i] = min[i];
                    }
                    else
                    {
                        long double nova = y1 - sqrtl(R * R - (abs(x - i) * abs(x - i)));
                        min[i] = (min[i] < nova) ? min[i] : nova;
                        visine[i] = min[i];
                    }
                }
            }
        }
        else
        {
            scanf("%ld",&Ai);
            printf("%.9Lf\n", visine[Ai]);
        }
    }
}