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

namespace Gric
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();

            int[] x1 = new int[100001];
            int[] x2 = new int[100001];
            int[] y1 = new int[100001];
            int[] d = new int[100001];
            double[] l = new double[100001];

            double odsecak;



            int w = Convert.ToInt32(str[0]);
            int h = Convert.ToInt32(str[1]);
            int r = Convert.ToInt32(str[2]);
            int q = Convert.ToInt32(str[3]);

            for (int i = 0; i < q; i++)
            {
                str = Console.ReadLine().Split();
                if (Convert.ToInt32(str[0]) == 1)
                {
                    d[i] = 1;
                    x1[i] = Convert.ToInt32(str[1]);
                    y1[i] = Convert.ToInt32(str[2]);
                }
                else
                {
                    d[i] = 2;
                    x2[i] = Convert.ToInt32(str[1]);
                }
            }

            int br = 0;
            int xt = 0;
            int yt = 0;


            bool k = false;

            for (int i = 0; i < q; i++)
            {
                if (d[i] == 2)
                {
                    if (k)
                    {
                        odsecak = Math.Sqrt(Convert.ToDouble(Math.Pow(r, 2)) - Convert.ToDouble(Math.Pow(xt-x2[i],2)));

                     

                        l[br] = Convert.ToDouble(yt) - odsecak;

                       


                        if (l[br]>h)
                        {
                            
                            l[br] = h;
                        }

                    }
                    else
                    {

                        l[br] = Convert.ToDouble(h);

                    }
                    br++;

                }
                else
                {
                    k = true;
                    xt = x1[i];
                    yt = y1[i];
                }
            }

            for (int i = 0; i < br; i++)
            {
               Console.WriteLine(l[i]);
            }

        }

      
    }
}