using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] unos = Console.ReadLine().Split();
            int w = int.Parse(unos[0]);
            int h = int.Parse(unos[1]);
            int r = int.Parse(unos[2]);
            int q = int.Parse(unos[3]);
            double[] visine = new double[w];
            for (int i = 0; i < w; i++)
                visine[i] = h;
            double[] konacne=new double[q];
            int f=0;
            for (int i = 0; i < q; i++)
            {
                string[] niz = Console.ReadLine().Split();
                int pr = int.Parse(niz[0]);
                if (pr == 2)
                {
                    konacne[f] = visine[int.Parse(niz[1])];
                    f++;
                }
                if (pr == 1)
                {
                    double u1 = 0;
                    for (int j = int.Parse(niz[1]); j < visine.Length; j++)
                    {
                        double h1 = double.Parse(niz[2]);
                        double pom = double.Parse((r * r).ToString());
                        double kona = h1 - Math.Sqrt((pom - u1 * u1));
                        if (kona > h)
                            visine[j] = h;
                        else
                            visine[j] = kona;
                        u1++;
                    }
                    u1 = 0;
                    for (int j = int.Parse(niz[1]); j >= 0; j--)
                    {
                        double h1 = double.Parse(niz[2]);
                        double pom = double.Parse((r * r).ToString());
                        double kona = h1 - Math.Sqrt((pom - u1 * u1));
                        kona=Math.Round(kona, 12);
                        if (kona > h)
                            visine[j] = h;
                        else if (visine[j] <= kona)
                        {
                            visine[j] = visine[j];
                        }
                        else
                        {
                            visine[j] = kona;
                        }
                        u1++;
                    }
                }
                    
            }
            Array.Resize(ref konacne, f);
            for (int i = 0; i < konacne.Length; i++)
                Console.WriteLine(konacne[i]);
        }
    }
}