//Failure will never overtake me if my determination to succeed is strong enough
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int w, h, q;
    double r;
    scanf("%d%d%lf%d", &w, &h, &r, &q);

    double a[w+1];

    for(int i = 0; i <= w; i++)
        a[i] = h;

    if(r <= 10 || q*w <= 10000007)
    {
        while(q--)
        {
            int u;
            scanf("%d", &u);
            if(u == 1)
            {
                int x, y;
                scanf("%d%d", &x, &y);

                for(int i = max(0, x-(int)r); i <= min(w, x+(int)r); i++)
                {
                    double ri = sqrt(r*r-(double)(i-x)*(i-x));

                    a[i] = min(a[i], (double)y-ri);
                }
            }

            else
            {
                int x;
                scanf("%d", &x);
                printf("%.12f\n", a[x]);
            }
        }
    }

}