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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = (Console.ReadLine()).Split(' ');
            int W = int.Parse(s[0]);
            int H = int.Parse(s[1]);
            int R = int.Parse(s[2]);
            int Q = int.Parse(s[3]);
            double[] xosa=new double[W+1];
            for (int i = 0; i <=W; i++)
            {
                xosa[i] = H;
            }
            int[][] zadatak = new int[Q][];

            for (int i = 0; i < Q; i++)
            {
                s = (Console.ReadLine()).Split(' ');
                zadatak[i] = Array.ConvertAll(s, int.Parse);

            }
            for (int i = 0; i < Q; i++)
            {
                switch (zadatak[i][0])
                {
                    case 1:
                        for (int b = 0; b <= W; b++)
                        {
                            if (((R * R) - ((zadatak[i][1] - b) * (zadatak[i][1] - b))) <= 0)
                            {
                                xosa[b] = H;

                            }

                            else if (b == zadatak[i][1])
                            {
                                xosa[b]= zadatak[i][2]-R;
                                if (xosa[b] < 0)
                                    xosa[b] = 0;
                            }

                            else
                            {
                                if(xosa[b] > (zadatak[i][2] - (Math.Sqrt((R * R) - ((zadatak[i][1] - b) * (zadatak[i][1] - b))))))
                                {
                                    xosa[b] = (zadatak[i][2] - (Math.Sqrt((R * R) - ((zadatak[i][1] - b) * (zadatak[i][1] - b)))));
                                }
                            }
                        }
                        break;

                    case 2:
                        Console.WriteLine(Math.Abs(xosa[zadatak[i][1]]));
                        break;
                    default:
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}