#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int a, b;
    cin>>a>>b;
    int r,q;
    cin>>r>>q;
    int p;
    int x, y;
    int xi;
    int xii[q-1];
    int k = 0;
    int por;
    for(int i=0;i<q;i++){
        cin>>p;
        if(p==1){
            cin>>x>>y;
            por=i;
        }
        if(p==2){
            cin>>xi;
            xii[k]=xi;
            k++;
        }
    }
    for(int i=0;i<q-1;i++){
        if(por>i){
            cout<<b<<endl;
        }else{
        double c = y-sqrt(pow(r,2)-pow((xii[i]-x),2));
        if(c>b){
            c=b;
        }
        cout<<c<<endl;
        }
    }
    return 0;
}