#include <bits/stdc++.h>
#include <algorithm> 
#include <cmath> 
#include <iomanip> 
#include <iostream> 
using namespace std;

int main()
{
    long long w;
    long long h;
    long long r;
    long long q;
    long long x;
    long long y;
    long double a;
    int cmd;

    long double td[100000];

    cin >> w >> h >> r >> q;

    fill(td, td + w, h);

    for(long long i = 0; i<q; i++)
    {
        cin >> cmd;

        if(cmd == 1)
        {
            cin >> x >> y;
            for (long long i = x-r; (i <= (x+r)) && (i <= x); i++)
            {
                a = sqrtl(r*r - (x-i) * (x-i));
                td[i] = std::min(td[i], y - a);
            }
        }

        else

        {
            cin >> x;
            cout << td[x] << endl;
        }
    }

	return 0;
}