import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int W = s.nextInt(), H = s.nextInt(), R = s.nextInt(), Q = s.nextInt();

        double najmanjaVisina = H;
        
        int xo = Integer.MAX_VALUE, yo = Integer.MAX_VALUE;
        for (int i = 0; i < Q; i++) {
            int event = s.nextInt();

            if (event == 1) {
                xo = s.nextInt();
                yo = s.nextInt();
            } else if (event == 2) {
                int xi = s.nextInt();
                double l = Math.abs(xo-xi);
                if (l >= R) {
                    System.out.println(H);
                } else {
                    double i1 = Math.sqrt(R*R - l * l);          
                    	
                    najmanjaVisina = yo-i1;

                    
                    System.out.println(najmanjaVisina);
                }
            }
        }
    }

}