#include <bits/stdc++.h>
#include <vector>

using namespace std;

int main(void)
{
    ios_base::sync_with_stdio(false);
    int W, H, R, Q;
    scanf("%d %d %d %d",&W, &H, &R, &Q);
    int num = 0, r = 1;
    vector<int> a;
    vector<int> bb;

    for(int t = 0; t < Q; t++){
        int b, b2;
        scanf("%d", &b);
        if(b == 2){
            scanf("%d", &b);
            for(int i = 0;i < num; i++){
                if(a[i] - R < b && b < a[i] + R){
                    r = 0;

                    printf("%.10f\n",(double)bb[i] - (double)sqrt(R * R - (a[i] - b) * (a[i] - b)));
                }
            }
            if(r == 1){
                printf("%.10f\n", (double) H);
            }
            r = 1;
        }else{
            scanf("%d %d", &b, &b2);
            num++;
            a.push_back(b);
            bb.push_back(b2);
        }
    }
}