#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

std::vector<int> GetInput()
{
	std::vector<int> input;
	int a;

	while (std::cin >> a)
	{
		input.push_back(a);

		if (cin.peek() == '\n')
		{
			break;
		}
	}

	return input;
}


int main()
{
	cout << fixed << setprecision(12);

	int W, H, R, Q;
	cin >> W >> H >> R >> Q;

	vector<int> inp;

	vector< vector<int> > event;

	for (int i = 0; i < Q; ++i)
	{
		inp = GetInput();
		event.push_back(inp);
	}

	int xc = -1;
	int yc = -1;

	long double l = -1.0;

	bool first = true;

	long double lp = -1;

	for (int i = 0; i < event.size(); ++i)
	{
		inp = event[i];

		if (inp[0] == 1)
		{
			xc = inp[1];
			yc = inp[2];
		}
		else if (inp[0] == 2)
		{
			if (xc == -1 && yc == -1)
			{
				l = H;
				cout << l << endl;
			}
			else
			{
				int xi = inp[1];

				long double t = sqrt((R * R) - ((xc - xi) * (xc - xi)));
				l = yc - t;
				if (l > H)
				{
					l = H;
				}
				if (first == true)
				{
					lp = l;
					first = false;
				}
				if (l > lp)
				{
					l = lp;
				}

				cout << l << endl;
			}
			lp = l;
		}
	}


	return 0;



}