#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>

using namespace std;

int n,w,r,q,a,b,x,y;
double v[100005],h;

int main()
{
    cin>>w>>h>>r>>q;
    if(r==1){
        for(int i=0;i<=w+1;i++)
        {
            v[i]=h;
        }
        for(int i=1;i<=q;i++)
        {
            cin>>a;
            if(a==2)
            {
                cin>>b;
                printf("%.9lf",v[b]);
                cout<<endl;
            }
            else if(a==1)
            {
                cin>>x>>y;
                v[x]=h-1;
            }
        }
    }
    else
    {
        for(int i=0;i<=w+1;i++)
        {
            v[i]=h;
        }
        for(int i=1;i<=q;i++)
        {
            cin>>a;
            if(a==2)
            {
                cin>>b;
//                cout<<v[b]<<endl;
                printf("%.9lf",v[b]);
                cout<<endl;
            }
            else if(a==1)
            {
                cin>>x>>y;
                if(y==h+1)
                {
                    v[x]=min(v[x],h-1);
                    v[x-1]=min(v[x-1],h-(1.0-sqrt(3)));
                    v[x+1]=min(v[x+1],h-(1.0-sqrt(3)));
                }
                else if(y==h)
                {
                    v[x]=min(v[x],h-2);
                    v[x-1]=min(v[x-1],h-sqrt(3));
                    v[x+1]=min(v[x+1],h-sqrt(3));
                }
            }
        }
    }
    return 0;
}