#include<bits/stdc++.h>

using namespace std;


long double racunanje(long long R,long long H,vector <long long> x,vector<long long> y,long long I,long long J){
	if(J==-1){
		return H;
	}
	else{
		long double rez;
		rez=sqrt(R*R-pow(abs(x[I]-x[J]),2));
	//	cout<<rez<<" PRVI MACICI"<<" krug x="<<x[1]<<"   ,   merenje x="<<x[4]<<endl;
		if(rez==0){
			return H;
		}
		else{
			rez=abs(y[J]-rez);
			return rez;
		}
	}
	
}

int main(){
	long long W,H,Q,R,t1,t2,J=-1;
	cin>>W>>H>>R>>Q;
	vector<long long> x;
	vector<long long> y;
	vector<long long>tip;
	for(long long i=0;i<Q;i++){
		cin>>t1;
		tip.push_back(t1);
		switch(tip[i]){
			case 1:{
				
				cin>>t1>>t2;
				x.push_back(t1);
				y.push_back(t2);
				break;
			}
			case 2:{
				cin>>t1;
				x.push_back(t1);
				y.push_back(-1);
				break;
			}
		}
	}
	cout<<setprecision(9)<<fixed;
	for(long long i=0;i<Q;i++){
		if(tip[i]==1){
			J=i;
		}
		else{
			cout<<racunanje(R,H,x,y,i,J)<<endl;
		}
	}
	
	return 1;
}