#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
long long double manji(long long double a, long long double b)
{
     if(a<b) return a;
     return b;
}
int main()
{
    
    long long int w,h,r,q;
    
    cin>>w>>h>>r>>q;
    int op;
    long long int x,y,l;
    long double a[w+1],b[q];
    int brojac=0;
    for(int i=0;i<w+1;i++)
        a[i]=h;
    for(int i=0;i<q;i++)
    {
       cin>>op;
       if(op==1)
       {
          cin>>x>>y;
          for(int j=0;j<w+1;j++)
          {
              if(a[j]>y-sqrt(r*r-(x-j)*(x-j)))
                  a[j]=y-sqrt(r*r-(x-j)*(x-j));
              //a[j]=manji(y-sqrt(r*r-(x-j)*(x-j)),a[j]);
          }
       }
       if(op==2)
       {
          cin>>l;
          b[brojac]=a[l];
          brojac++;
       }
    }
    
    
    for(int i=0;i<brojac;i++)
         cout<<b[i]<<endl;
    
    return 0;
}