#include <bits/stdc++.h>
using namespace std;
double currHeights[100005];
int w, h, r, q;
void calculateCircle(int x, int y)
{
    for (int i = x-r; i <= x+r; i++) {
        int dist = x-i;
        double theta = acos((double)dist/r);
        currHeights[i] = min(currHeights[i], y-r*sin(theta));
    }
}
int main()
{

    cin >> w >> h >> r >> q;
    for (int i = 0; i <= w; i++)
        currHeights[i] = h;
    int x, y, z;
    for (int i = 0; i < q; i++) {
        cin >> x;
        if (x == 1)
        {
            cin >> y >> z;
            calculateCircle(y, z);
        }
        else {
            cin >> y;
            cout << fixed << setprecision(9) << currHeights[y] << "\n";
        }
    }
    return 0;
}