using System;
using System.Collections.Generic;
class Program {
    static void Main() {
        string s = Console.ReadLine();
        string[] a = s.Split(null);
        int W = int.Parse(a[0]);
        int H = int.Parse(a[1]);
        int R = int.Parse(a[2]);
        int Q = int.Parse(a[3]);
        int i, c, Gx, Gy, Cx;
        double l;
        List<double> ListX = new List<double>();
        List<string> ListS = new List<string>();
        List<string> ListCx = new List<string>();
        List<string> ListGx = new List<string>();
        List<string> ListGy = new List<string>();
        for(i = 0; i <= W; i++) { ListX.Add(H); }
        for(i = 1; i <= Q; i++) {
            s = Console.ReadLine();
            a = s.Split(null);
            if(a[0] == "2") {
                ListS.Add(a[0]);
                ListCx.Add(a[1]);
                ListGx.Add("-1");
                ListGy.Add("-1");
            }
            else if(a[0] == "1") {
                ListS.Add(a[0]);
                ListCx.Add("-1");
                ListGx.Add(a[1]);
                ListGy.Add(a[2]);
            }
        }
        Cx = 0;
        Gx = W + R;
        Gy = H + R;
        c = ListS.Count;
        for(i = 0; i < c; i++) {
            if(ListS[i] == "2") {
                Cx = int.Parse(ListCx[i]);
                l = H - ((Math.Sqrt((R*R) - ((Gx - Cx) * (Gx - Cx)))) - (Gy - H));
                if((Gx == W+R && Gy == H+R) || (Gx-R) >= Cx) { ListX[Cx] = H; }
                else if(l <= 0) { ListX[Cx] = 0; }
                else { ListX[Cx] = l; }
                Console.WriteLine("{0:0.000000000}", ListX[Cx]);
            }
            else if(ListS[i] == "1") {
                Gx = int.Parse(ListGx[i]);
                Gy = int.Parse(ListGy[i]);
                l = H - ((Math.Sqrt((R*R) - ((Gx - Cx) * (Gx - Cx)))) - (Gy - H));
                if(Gx == W+R && Gy == H+R) { ListX[Cx] = H; }
                else if(l <= 0) { ListX[Cx] = 0; }
                else { ListX[Cx] = l; }
            }
        }
    }
}