#include <iostream>
#include <vector>
#include <math.h>

double sqrt9( const double fg)
{
 double n = fg / 2.0;
 double lstX = 0.0;
 while(n != lstX)
 {
 lstX = n;
 n = (n + fg/n) / 2.0;
 }
 return n;
 }

using namespace std;
long int w,h,r,q;
vector<vector<long double>> events;
vector<vector<long double> *> circles;
int main()
{
    cout.precision(13);
    std::ios::sync_with_stdio(false);

    cin >> w >> h >> r >> q;
    for (long int i = 0; i < q; i++) {
        short int g;
        cin >> g;
        vector<long double> event;
        if (g==1) {
            long int x,y;
            cin >> x >> y;
            event.push_back(1);
            event.push_back(x);
            event.push_back(y);
        } else {
            long int x;
            cin >> x;
            event.push_back(2);
            event.push_back(x);
        }
        events.push_back(event);
    }

    for (long int i = 0; i < q; i++) {
        //cout << "shit, i: " << i << endl;
        if (events[i][0] == 2) {
                //cout << "yeet, i: " << i << endl;
            long double minn = h;
            for (long int c = 0; c < circles.size(); c++) {
                vector<long double> &circle = *circles[c];
                long double x = circle[1];
                long double y = circle[2];
                long double a = events[i][1];
                long double vrednost = y-sqrt9(r*r - (x-a)*(x-a));
                //cout << r << " " << x << " " << a << endl;
                if (vrednost < minn) minn = vrednost;
            }
            cout << minn << endl;
        }
        else {
            circles.push_back(&events[i]);
        }
    }

    return 0;
}