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

int main(void){
  long int w, h, r, q, x1, y1, xi, d, v;
  int b=0;
  long double nema, yt;
  scanf("%ld %ld %ld %ld",&w,&h,&r,&q);
  long double nizcina[q];
  for(long int i=0;i<q;i++){
    scanf("%ld",&v);
    if (v==2) {
      scanf("%ld",&xi);
      if (b==0) {
        yt=h;
      }
      else {
        long int xl=labs(x1-xi);
        if ((x1-nema)>=xi || (x1+nema)<=x1) yt=h;
        else yt=y1-sqrt(r*r-xl*xl);
      }
      nizcina[i]=yt;
    }
    if (v==1) {
      scanf("%ld %ld",&x1,&y1);
      d=y1-h;
      nema=sqrt(r*r-d*d);
      nizcina[i]=0;
      b++;
    }
  }
  printf("a\b");
  for(int j=0;j<q;j++){
    if (nizcina[j]!=0) printf("%.9Lf\n", nizcina[j]);
  }
  return 0;
}