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

int main() {
  long int w, h, r, q, i, di, xi, ai, bi, a, b;
  double yi;
  cin >> w >> h >> r >> q;
  for (i = 0; i < q; i++) {
    cin >> di;

    if (di == 1) {
      cin >> ai >> bi;
      a = ai;
      b = bi;
    }
    else {
      cin >> xi;
      if (i == 0) yi = h;
      else {
        yi = b - sqrt(pow(r, 2) - pow(xi - a, 2));
        if (yi > h) yi = h;
        if (yi < 0) yi = 0;
      }
      cout << setprecision(10) << yi;
    }
  }
  return 0;
}