#include <iostream>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
 #include <queue>
 #define MAX 100000

using namespace std;

int w, h, r, q;
double duzine[MAX];
queue <double> red;
int dog[MAX][3];

void unesi()
{
    int i;
    for(i = 0; i <= w; ++i){
        duzine[i] = h;
    }

    for(i = 0; i < q; ++i){
        scanf("%i", &dog[i][0]);
        if(dog[i][0] == 1){
            scanf("%i %i", &dog[i][1], &dog[i][2]);
            continue;
        }
        if(dog[i][0] == 2){
            scanf("%i", &dog[i][1]);
            continue;
        }
    }
}

void sacuvajDuzinu(int x)
{
     red.push(duzine[x]);
}

void ispisiDuzine()
{
    while(!red.empty()){
        printf("%.12f\n", red.front());
        red.pop();
    }
}

double razlika(int x, int xr, int yr, double duzina)
{
    double dy;
    double dx = abs(xr - x);
    if(dx == 0){
        if(yr - r < duzina){
            return yr - r;
        }
        else{
            return duzina;
        }
    }
    else{
        dy = sqrt(r*r - dx*dx);
        if(dy == 0){
            return duzina;
        }
        else{
            if(yr - dy < duzina){
                return yr - dy;
            }
            else{
                return duzina;
            }
        }
    }
}

void izmeni()
{
    for(int i = 0; i < q; ++i){
        if(dog[i][0] == 1)
        {
            for(int x = 0; x <= w; ++x){
                duzine[x] = razlika(x, dog[i][1], dog[i][2], duzine[x]);
            }
            continue;
        }
        if(dog[i][0] == 2)
        {
            sacuvajDuzinu(dog[i][1]);
            continue;
        }
    }
}

int main()
{
    scanf("%i %i %i %i", &w, &h, &r, &q);
    unesi();
    izmeni();
    ispisiDuzine();
}