#include <bits/stdc++.h>

using namespace std;

int main()
{
    double W,H,R,Q;
    vector<double> x;
    vector<double> y;
    cin >> W >> H >> R >> Q;
    for(int i = 0;i<Q;i++)
    {
        int pom;
        cin >> pom;
        if(pom == 1)
        {
            double pom1,pom2;
            cin >> pom1 >> pom2;
            x.push_back(pom1);
            y.push_back(pom2);
        }
        else if(pom == 2)
        {
            // Meri
            double m,len;
            cin >> m;
            double minimum = 1e100;
            double test;
            for(int i = 0;i < x.size();i++)
            {
                test = y.at(i)- sqrt((R*R) - (abs(m-x.at(i))*abs(m-x.at(i))));
                if(minimum > test)
                    minimum = test;
            }
            len = min(minimum,H);
            cout << fixed << setprecision(9) << len <<endl;
        }
    }
    return 0;
}