#include <bits/stdc++.h>

using namespace std;

int main()
{
    long w,h,r,q, num, x, y;
    cin >> w >> h >> r >> q;
    long pocetnoH = h;
    vector<long double> sol;
    long double niz[w];
    for(int i=0;i<w;i++)niz[i] = (long double)h;
    for(int i=0;i<q;i++)
    {
        cin >> num;
        if(num==1)
        {
           cin >> x >> y;
           for(long j=max((long double)0, (long double)x-sqrt((long double)r*r - (long double)(y-pocetnoH)*(y-pocetnoH)));j<min((long double)w, (long double)x+sqrt((long double)r*r - (long double)(y-pocetnoH)*(y-pocetnoH)));j++)
           {
               niz[j] = min((long double)y - sqrt((long double)(r*r) - (long double)(x-j)*(x-j)), niz[j]);
           }
        }
        else
        {
            cin >> x;
            sol.push_back(niz[x]);
        }
    }
    for(auto x : sol)cout << setprecision(13) << x << endl;
    return 0;
}