#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(){
    cout.precision(16);

    int w,h,r,q;
    cin >> w >> h >> r >> q;

    int type;
    int x,y;
    vector<long double> lenjir(w+1,h);
    vector<long double> odgovor;

    for(int i = 0; i < q; i++){
        cin >> type;
        if(type == 1){
            cin >> x;
            cin >> y;
            for(int j = 0; j <= w; j++){
                long double b = x - j;
                long double a = sqrt(pow(r,2) - pow(b,2));
                long double nh = y - a;
                if(nh < lenjir[j] && (j < x + r) && (j > x -r)){
                    lenjir[j] = nh;
                }
            }

        }else{
            cin >> x;
            odgovor.push_back(lenjir[x]);
        }
    }

    for ( auto x : odgovor){
        cout << x << endl;
    }
    return 0;
}