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

using namespace std;

int main(){
    int w,h,r,q;
    cin >> w >> h >> r >> q;

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

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