#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	int r;
	cin>>r;
	int tt;
	cin>>tt;
	vector<int> x;
	vector<int> y;
	int pos[w]={-1};
	cout<<fixed<<setprecision(9);
	while(tt--)
	{
		int tip;
		cin>>tip;
		if(tip==1)
		{
			int a,b;
			cin>>a>>b;
			x.push_back(a);
			y.push_back(b);
			pos[a]=min(pos[a],b);
			if(pos[a]==-1)
				pos[a]=b;
		}
		else
		{
			int a;
			cin>>a;
			int i;
			//int maxa=10000000;
			double ans=w;
			for(i=0;i<(int)x.size();i++)
			{
				ans=min(ans,pos[x[i]]-sqrt(r*r-abs(x[i]-a)*abs(x[i]-a)));
			}
			cout<<ans<<endl;
		}
	}
}