#include <bits/stdc++.h>

using namespace std;

int main()
{
    double W,H,R,Q;
    double x = 0;
    double y = 1e6;
    cin >> W >> H >> R >> Q;
    for(int i = 0;i<Q;i++)
    {
        int pom;
        cin >> pom;
        if(pom == 1)
        {
            // Grizi
            cin >> x;
            cin >> y;
        }
        else if(pom == 2)
        {
            // Meri
            double m,len;
            cin >> m;
            len = min(y- sqrt((R*R) - (abs(m-x)*abs(m-x))),H);

            cout << fixed << setprecision(9) << len <<endl;
        }
    }
    return 0;
}