#include<bits/stdc++.h>
using namespace std;
double krug(double xc,double yc,double r, double x, double h){
	if(h+r<=yc||x+r<=xc||x-r>=xc)return h;
	double a=abs(xc-x);
	double b=sqrt(r*r-a*a);
	double h1=yc-b;
	return h1;
}
int main(){
	double a,b,r,n,pom;
	cin>>a>>b>>r>>n;
	vector<double> x,y,re;
	for(int i=0;i<n;i++){
		cin>>pom;
		if(pom==1){
			cin>>pom;
			x.push_back(pom);
			cin>>pom;
			y.push_back(pom);
		}
		else{
			cin>>pom;
			double mini=b;
			int d=x.size();
			for(int j=0;j<d;j++){
				mini=min(mini,krug(x[j],y[j],r,pom,b));
			}
			re.push_back(mini);
		}
	}
	int d=re.size();
	cout<<fixed;
	cout<<setprecision(10);
	for(int i=0;i<d;i++)cout<<re[i]<<endl;
}