#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int w;
    int h;
    int r;
    int q;
    cin >> w;
    cin >> h;
    cin >> r;
    cin >> q;
    int *x = new int[q];
    int *y = new int[q];
    int vel = 0;
    double *res = new double[q];
    int duz = 0;
    for(int i = 0; i < q; i++){
        int sl;
        cin >> sl;
        if(sl == 1){
            cin >> x[vel];
            cin >> y[vel];
            vel++;
        }
        else{
            int k;
            cin >> k;
            double nk = 100001;
            for(int j = 0; j < vel; j++){
                if(sqrt(x[j]*x[j] - 2*x[j]*k + k*k + y[j]*y[j] - 2*y[j]*h + h*h) < r){
                    if(j == 0) nk = y[j] - sqrt(r*r - x[j]*x[j] + 2*x[j]*k - k*k);
                    else if(nk > y[j] - sqrt(r*r - x[j]*x[j] + 2*x[j]*k - k*k)) nk = y[j] - sqrt(r*r - x[j]*x[j] + 2*x[j]*k - k*k);
                }
            }
            if(nk < 100001) res[duz] = nk;
            else res[duz] = h;
            duz++;
        }
    }
    for(int h = 0; h < duz; h++){
        cout << res[h] << endl;
    }
    return 0;
}