#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

double keks[100000];

int main()
{
    int w, h, r, q, x, y;
    short op;
    scanf("%d%d%d%d", &w, &h, &r, &q);

    for(int i = 0; i < w; i++)
        keks[i] = h;

    for(int i = 0; i < q; i++)
    {
        scanf("%hd", &op);

        if(op == 1)
        {
            scanf("%d%d", &x, &y);

            for(int j = x - r + 1; j < x + r; j++)
                keks[j] = min(keks[j], (double)y - sqrt(r * r - (x - j) * (x - j)));
        }
        else
        {
            scanf("%d", &x);
            printf("%.12lf\n", keks[x]);
        }
    }

    return 0;
}