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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            double W = Convert.ToDouble(s[0]);
            double H = Convert.ToDouble(s[1]);
            double R = Convert.ToDouble(s[2]);
            double Q = Convert.ToDouble(s[3]);
            double x=0;
            double y=0;
            double x2;
            double[] xi = new double[(int)W+1];
            for (int i = 0; i <= W; i++)
                xi[i]=H;
            for(int i = 0; i<Q;i++)
            {
               string[] sl = Console.ReadLine().Split(' ');

                if(sl[0]=="1")
                {
                    x =Convert.ToDouble(sl[1]);
                    y = Convert.ToDouble(sl[2]);
                    for(int j = 0; j<=W;j++)
                    {
                        if(xi[j]>y - (Math.Sqrt(Math.Pow(R, 2) - Math.Pow(Math.Abs(x - j), 2))))
                        xi[j]= y - (Math.Sqrt(Math.Pow(R, 2) - Math.Pow(Math.Abs(x - j), 2)));
                    }
                }
                if(sl[0]=="2")
                {
                    x2 = Convert.ToDouble(sl[1]);
                    Console.WriteLine(xi[(int)x2]);
                }
            }
        }
    }
}