#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    	cout << setprecision(numeric_limits<double>::digits10 + 1);
        	unsigned w, h, r, q;
            	cin >> w >> h >> r >> q;
                	unsigned n = w/r + (w%r ? 1 : 0);
                    	vector<vector<pair<unsigned, unsigned>>> gric(n, vector<pair<unsigned, unsigned>>());
                        	unsigned r2 = r*r;
                            	while (q--)
                                	{
                                    		int upit;
                                            		cin >> upit;
                                                    		if (upit == 1)
                                                            		{
                                                                    			unsigned x, y;
                                                                                			cin >> x >> y;
                                                                                            			gric[x/r].push_back(make_pair(x, y));
                                                                                                        		}
                                                                                                                		else
                                                                                                                        		{
                                                                                                                                			unsigned x;
                                                                                                                                            			double y = h;
                                                                                                                                                        			cin >> x;
                                                                                                                                                                    			unsigned x2 = x*2, xx = x*x;
                                                                                                                                                                                			#define a(indeks) for (auto par : gric[indeks]) y = min(y, par.second - sqrt(r2 + par.first*(x2 - par.first) - xx));
                                                                                                                                                                                            			a(x/r)
                                                                                                                                                                                                        			if (x/r + 1 < n)
                                                                                                                                                                                                                    				a(x/r + 1)
                                                                                                                                                                                                                                    			if (x/r > 0)
                                                                                                                                                                                                                                                				a(x/r - 1)
                                                                                                                                                                                                                                                                			cout << y << '\n';
                                                                                                                                                                                                                                                                            		}
                                                                                                                                                                                                                                                                                    	}
                                                                                                                                                                                                                                                                                        }