#include <bits/stdc++.h>

using namespace std;

double meri(double a[], double x){
    return a[(int)x];
}

void seci(double a[], double w, double r, double x, double y){
    for(int i = abs(x - r) + 1;i < min(x + r, w);i++){
        if(i == x)
            a[i] = abs(y - r);
        else
            a[i] = abs(y - sqrt(pow(r, 2) - pow(abs(x - i), 2)));
    }
}

int main(){
    ios::sync_with_stdio(false);
    double w, h, r, q;
    cin >> w >> h >> r >> q;
    double a[(int)w+1];
    for(int i = 0;i <= w;i++)
        a[i] = h;
    int p;
    double x, y;
    for(int i = 0;i < q;i++){
        cin >> p;
        if(p == 2){
            cin >> x;
            cout << fixed << showpoint << setprecision(12) << meri(a, x) << '\n';
        }
        else if(p == 1){
            cin >> x >> y;
            seci(a, w, r, x, y);
        }
    }
    return 0;
}