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

int main()
{	

	cout << fixed << setprecision( 9 );
	int a, x, br = 0, brK = 0;
	int i, j, brO = 0;
	int W, H, R, Q;
	
	cin >> W >> H >> R >> Q;
	
	long double min, pom, R2, dx;
	long double odgovori[ Q ];
	int kruznice[ Q ][ 2 ];
	
	R2 = ( long double )R * ( long double )R;
	
	for( i = 0; i < Q; ++i )
	{
		cin >> a;
		
		if( a == 1 )
	 	{
	 		cin >> kruznice[ brK ][ 0 ]
	 			>> kruznice[ brK ][ 1 ];
	 		
	 		++brK;
		}
		else
		{
			cin >> x;
			
			min = H;
			
			for( j = 0; j < brK; ++j )
			{
				dx = kruznice[ j ][ 0 ] - x;
				dx*= dx;
				
				pom = pow( R2 - dx, 0.5 );
				pom = kruznice[ j ][ 1 ] - pom;
				
				
				if( pom < min )
					min = pom;
			}
			
			odgovori[ br++ ] = min;
			
		}
	}
	
		
	for( i = 0; i < br; ++i )
		cout << odgovori[ i ] << endl;
	
	return 0;
}