#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = (int) 1e5+99;
int q;
double w, h, r;
double vis[N];
int main() {
    cout << fixed << setprecision(10) << showpoint;
    IOS; cin >> w >> h >> r >> q;
    for(int i=0; i<=w; ++i) vis[i] = h;
    while(q--) {
        int t; double x; cin >> t >> x;
        if(t==1) {
            double y; cin >> y;
            for(int aa=0; aa<=w; ++aa) {
                double a = (double)aa;
                vis[aa] = min(vis[aa], y-sqrt(r*r-(a-x)*(a-x)));
            }
        }
        else cout << vis[(int)x] << endl;
    }
    return 0;
}