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

struct tacka{
long int x,y;
};

struct tacka centar[100000];

double d[100000];


void smanji(long int x,long int c,long int r){
    double m;
    for(long int i=0;i<c;i++){
        m=centar[i].y-sqrt(pow(r,2)-pow(centar[i].x-x,2));
        if(m<d[x]){
            d[x]=m;
        }
        if(d[x]<0){
            d[x]=0;
        }
    }
}

int main()
{
    long int w,h,r,q,x,y;
    long int c=0;
    int m=0;
    scanf("%ld %ld %ld %ld",&w,&h,&r,&q);
    for(long int i=0;i<=w;i++){
        d[i]=-1;
    }
    for(long int i=0;i<q;i++){
        scanf("%d",&m);
        if(m==1){
            scanf("%ld %ld",&x,&y);
            centar[c].x=x;
            centar[c++].y=y;
        }
        else{
            scanf("%ld",&x);
            if(d[x]==-1){d[x]=h;}
            smanji(x,c,r);
            printf("%lf\n",d[x]);
        }
    }
    return 0;
}