#include <iostream>
#include <cmath>
#include <vector>

//#define DEBUG

using namespace std;

typedef long double ld;

ld r;

class gric{
public:
    ld x, y;
    ld getY(ld x0){
#ifdef DEBUG
        cout << "r = " << r << ", x = " << x << ", x0 = " << x0 << endl;
#endif // DEBUG
        if(r*r <= (x-x0)*(x-x0)){
            return -1;
        }
        return y-sqrt(r*r - (x-x0)*(x-x0));
    }

};

int main()
{
    ld w, h;
    int q;
    vector<gric> vec;
    vector<ld> res;
    cin >> w >> h >> r >> q;
    int f;
    ld x, min, t;
    int s = -1;
    for(int i = 0; i < q; ++i){
        cin >> f;
        if(f == 1){
            vec.push_back(gric());
            ++s;
            cin >> vec[s].x >> vec[s].y;
        }
        else{
            cin >> x;
            if(s < 0){
                res.push_back(h);
            }
            else{
                min = vec[0].getY(x);
                if(min < 0){
                    min = h;
                }
                for(int i = 1; i <= s; ++i){
                    t = vec[i].getY(x);
                    if(t < 0){
                        t = h;
                    }
                    if(t < min){
                        min = t;
                    }
                }
                res.push_back(min);
            }
        }
    }
    for(int i = 0; i < res.size(); ++i){
        cout << res[i] << endl;
    }
    return 0;
}