#include <bits/stdc++.h>
using namespace std;
vector <int> x, y;
long double niz[100005];
long double f(int X, int Y, int R, int I)
{
    return Y-sqrt(R*R - (X - I)*(X - I));
}
int main()
{
    int w, h, r, q, i, wx, x1, y1;
    ios_base::sync_with_stdio(false);
    cin >> w >> h >> r >> q;
    for(i = 0; i <= w; i++) niz[i] = h;
    while(q)
    {
        cin >> i;
        if(i == 1)
        {
            cin >> x1 >> y1;
            i = min(0, x1 - r);
            while(i <= x1 + r)
            {
                niz[i] = min(niz[i], f(x1, y1, r, i));
                i++;
            }
        }
        else
        {
                cin >> wx;
                cout << setprecision(15) << niz[wx] << endl;
        }
        q--;
    }
    return 0;
}