#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#define newl '\n'
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << x << endl;
#define MAXN 100001
using namespace std;

int w, h, r, q;
long double height[MAXN + 1];

struct circle
{
	int x;
	int y;
};

int main()
{
	cin >> w >> h >> r >> q;
	cout << setprecision(10);
	vector<circle> c;
	int r_sq = r * r;
	for (int i = 0; i < w + 1; i++) height[i] = (long double)h;
	while (q--)
	{
		int x;
		char cmd; cin >> cmd >> x;
		if (cmd == '1')
		{
			int y; cin >> y;
			c.push_back({x, y});
		}
		else //cmd = 2
		{ 
			for (int i = 0; i < c.size(); i++)
			{
				int rx = c[i].x;
				int ry = c[i].y;
				double dist = abs(rx-x);
				if (x > rx - r && x < rx + r)
				{
					height[x] = min(height[x], (long double)ry - sqrtl(r_sq - dist * dist));
				}
			}
			cout << height[x] << newl;
		}
	}
}