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

namespace _5.gric
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ulaz = Console.ReadLine().Split();
            int w = Convert.ToInt32(ulaz[0]);
            int h = Convert.ToInt32(ulaz[1]);
            double r = Convert.ToInt32(ulaz[2]);
            int n = Convert.ToInt32(ulaz[3]);

            int[,] podaci = new int[3, n];
            for(int i = 0; i < n; i++)
            {
                string[] ulazz = Console.ReadLine().Split();
                podaci[0, i] = Convert.ToInt32(ulazz[0]);
                podaci[1, i] = Convert.ToInt32(ulazz[1]);
                if(podaci[0, i] == 1)
                podaci[2, i] = Convert.ToInt32(ulazz[2]);
            }
            double[] max = new double[w + 1];
            for (int i = 0; i < w + 1; i++) max[i] = h;
            double rez;
            for(int i = 0; i < n; i++)
            {
                if (podaci[0, i] == 1)
                {
                    for(int j = 0; j< r; j++)
                    {
                        if (podaci[1, i] + j <= w)
                        {
                            rez = podaci[2, i] - (r * Math.Cos(Math.Asin(j / r)));
                            if(rez < max[podaci[1, i] + j])
                            {
                                max[podaci[1, i] + j] = rez;
                            }
                        }
                        if (podaci[1, i] - j >= 0)
                        {
                            rez = podaci[2, i] - (r * Math.Cos(Math.Asin(j / r)));
                            if(rez < max[podaci[1, i] - j])
                            {
                                max[podaci[1, i] - j] = rez;
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine(max[podaci[1, i]]);
                }
            }


        }
    }
}