#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
    int w,h;
    cin >> w >> h;
    double hm[h+1];
    for(int i=0;i<=h;i++){
        hm[i]=h;
    }
    
    int r, q;
    cin >> r >> q;
    int brans=0;
    double ans[q]; 
   // cout << "OK1" << endl;
    for(int i=0;i<q;i++){
        int p;
        cin >> p;
        if(p==1){
           /// cout << "OK2.1" << endl;
            int x,y;
            cin >> x >> y;
            
            for(int i=max(0,x-r);i<min(w,x+r);i++){
                double in=y-sqrt(r*r-(i-x)*(i-x));
                hm[i]=min(hm[i],in);
            }
        }else{
           /// cout << "OK2.2" << endl;
            int x;
            cin >> x;
            ans[brans]=hm[x];
            brans++;
        }
    }
    
    cout << fixed;
    cout << setprecision(9);
    
    for(int i=0;i<brans;i++){
        //cout << "OK3" << endl;
        cout << ans[i] << endl;
    }
    return 0;
}