#include <bits/stdc++.h>
using namespace std;
vector <int> x, y;
long double f(int X, int Y, int R, int I)
{
    return Y-sqrt(R*R - (X - I)*(X - I));
}
int main()
{
    int w, h, r, q, i, wx;
    long double mn;
    ios_base::sync_with_stdio(false);
    cin >> w >> h >> r >> q;
        while(q)
        {
            cin >> i;
            if(i == 1)
            {
                cin >> i;
                x.push_back(i);
                cin >> i;
                y.push_back(i);
            }
            else
            {
                cin >> wx;
                mn = h;
                for(i = 0; i < (int)x.size(); i++) if(f(x[i], y[i], r, wx) < mn) mn = f(x[i], y[i], r, wx);
                cout << setprecision(15) << mn << endl;
            }
            q--;
        }
    
    return 0;
}