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

namespace ConsoleApplication4
{
    class Program
    {
        static void provera(double a, double xi, double yi, ref double zbir, double h, double r)
        {
            if (a + r == xi || yi - h >= h)
            {
                zbir = h;
            }
            else if (yi - h < h && a+r!=xi)
            {
                zbir = yi - Math.Sqrt(Math.Pow(r, 2) - Math.Pow(xi - a, 2));
            }
        }
        static void Main(string[] args)
        {
            double xi = -1, yi = -1, raz = 0;
            int m = 0;
            string[] p = Console.ReadLine().Split();
            double w = Convert.ToDouble(p[0]);
            double h = Convert.ToDouble(p[1]);
            double r = Convert.ToDouble(p[2]);
            int n = Convert.ToInt32(p[3]);
            double[] l = new double[n];
            for (int i = 0; i < n; i++)
            {
                string[] k = Console.ReadLine().Split();
                if (Convert.ToDouble(k[0]) == 2 && xi == -1 && yi == -1)
                {
                    l[m] = h;
                    m++;
                }
                else if (Convert.ToInt32(k[0]) == 1)
                {
                    xi = Convert.ToDouble(k[1]);
                    yi = Convert.ToDouble(k[2]);
                }
                else if (Convert.ToDouble(k[0]) == 2 && xi != -1 && yi != -1)
                {
                    provera(Convert.ToDouble(k[1]), xi, yi, ref raz, h, r);
                    l[m] = raz;
                    m++;
                }
            }
            for (int i = 0; i < m; i++)
            {
                Console.WriteLine(l[i]);
            }
            Console.ReadLine();
        }
    }
}