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

using namespace std;

typedef long long ll;

struct Tacka {
    ll x;
    ll y;
};

Tacka najblizi(vector<Tacka> centri, Tacka temp) {
    long double dist;
    Tacka temp2;
    for(auto t = centri.begin(); t != centri.end(); ++t) {
        if(t == centri.begin()) {
            dist = hypot(temp.x - t -> x, temp.y - t -> y);
            temp2 = *t;
        } else if(dist < hypot(temp.x - t -> x, temp.y - t -> y)) {
            dist = hypot(temp.x - t -> x, temp.y - t -> y);
            temp2 = *t;
        }
    }
    return temp2;
}

long double procitaj(ll W, ll H, ll R, vector<Tacka> centri, Tacka temp) {
    long double dist;
    if(centri.size() == 0) {
        return temp.y;
    } else {
        Tacka centar = najblizi(centri, temp);
        if(hypot(temp.x - centar.x, temp.y - centar.y) > R) return temp.y;

        return centar.y - sqrt(R*R - pow(temp.x - centar.x, 2));
    }
}

long double zagrizi() {

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    long long int W,H,R,Q,tempI = 0;
    vector<Tacka> centri;

    cin >> W >> H >> R >> Q;

    long double niz[Q];

    for(int i = 0; i < Q; ++i) {
        int t;
        cin >> t;
        if(t == 2) {
            Tacka temp;
            cin >> temp.x;
            temp.y = H;
            niz[tempI] = procitaj(W,H,R,centri,temp);
            tempI++;
        }
        if(t == 1) {
            Tacka temp;
            cin >> temp.x;
            cin >> temp.y;
            centri.push_back(temp);
        }
    }

    for(int i = 0; i < tempI; ++i) {
        cout << fixed << setprecision(9) << niz[i] << "\n";
    }


    return 0;
}