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[] s = Console.ReadLine().Split();
            double a = double.Parse(s[0]);
            double b = double.Parse(s[1]);
            double r = double.Parse(s[2]);
            double n = double.Parse(s[3]);           
            double x1 = 0, y1 = 0, q = 0, m;
            for (int i = 0; i < n; i++)
            {
                string[] s1 = Console.ReadLine().Split();
                double p = double.Parse(s1[0]);
                double x = double.Parse(s1[1]);
                if (p == 1)
                {
                    x1 = x;
                    y1 = double.Parse(s1[2]);
                    q = 1;
                }
                if ((p == 2) && (q != 1 || (q == 1 && y1 - Math.Sqrt(r * r - ((x1 - x) * (x1 - x))) >= b)))Console.WriteLine(b.ToString("0.000000000"));
                else if (p == 2)
                {
                    m = y1 - Math.Sqrt(r * r - ((x1 - x) * (x1 - x)));
                    Console.WriteLine(m.ToString("0.000000000"));
                }
            }
        }
    }
}