#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=((k+1)*(m-1))-1;i<p;i=i+n-1)
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1));i<p;i=i+n-1)
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        long long int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        long long int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1));i<p;i=i+1+(n-m))
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1));i<p;i=i+(n-1))
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=1;i<=p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=1;i<=p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=1;i<=p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1))+1;i<=p;i=i+1+(n-m))
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1));i<p;i=i+1+(n-m))
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1));i<p;i=i+((n-1)*(m-1)))
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
int fun(int n)
{
    if(n%2==0)
        return n/2;
    else
        return (n/2)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int p=n*k;
        int arr[p];
        int ans=0;
        for(int i=0;i<p;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+p);
        int m=fun(n);

        if(n==1)
        {
            for(int i=0;i<p;i++){
                ans+=arr[i];
            }
            cout<<ans<<endl;
        }
        else if(n==2)
        {
            for(int i=0;i<p;i=i+2)
            {
                ans=ans+arr[i];
            }
            cout<<ans<<endl;
        }
        else{
        for(int i=(k*(m-1));i<p;i=i+(n-m))
        {
            ans=ans+arr[i];

        }
        cout<<ans<<endl;
        }

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;
    int a[length];

    int total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;
    step = n - step;

    for (int i = 0; i < length; i++) cin >> a[i];
    int i = length - 1;

    for (int j = 0; j < k; j++)
    {
        i -= step;
        total += a[i];
        i--;
    }
    cout << total << endl;

}

int main()
{
    int t;
    cin >> t;
    while(t--) task();
    task();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;
    int a[length];

    int total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;

    for (int i = 0; i < length; i++) cin >> a[i];
    int i = length - 1;

    for (int j = 0; j < k; j++)
    {
        i -= step;
        total += a[i];
        i--;
    }
    cout << total << endl;

}

int main()
{
    int t;

    cin >> t;

    while(t--) task();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;
    int a[length];

    long long total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;
    step = n - step;

    for (int i = 0; i < length; i++) cin >> a[i];
    int i = length - 1;

    for (int j = 0; j < k; j++)
    {
        i -= step;
        total += a[i];
        i--;
    }
    cout << total << endl;

}

int main()
{
    int t;
    cin >> t;
    while(t--) task();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;

    int total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;
    int start = ((step - 1) * k) + 1;
    if (n % 2 == 0)step++;

    for (int i = 1; i <= length; i++)
    {
        cin >> temp;
        if (i >= start && ((i % step) - 1) == 0) total += temp;
    }
    cout << total << endl;
}

int main()
{
    int t;

    cin >> t;
    while(t--) task();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;
    int a[length];

    int total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;

    for (int i = 0; i < length; i++) cin >> a[i];
    int i = length - 1;

    for (int j = 0; j < k; j++)
    {
        i -= step;
        cout << a[i] << endl;
        total += a[i];
        i--;
    }
    cout << total << endl;

}

int main()
{
    int t;

    cin >> t;

    while(t--) task();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;
    int a[length];
    memset(a, length, 0);
    int total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;

    for (int i = 0; i < length; i++) cin >> a[i];
    int i = length - 1;

    for (int j = 0; j < k; j++)
    {
        i -= step;
        total += a[i];
        i--;
    }
    cout << total << endl;

}

int main()
{
    int t;

    cin >> t;

    while(t--) task();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void task()
{
    int n, k, temp;
    cin >> n >> k;
    int length = n * k;
    int a[length];

    int total = 0;
    int step = n / 2;
    if (n % 2 == 1) step++;
    step = n - step;

    for (int i = 0; i < length; i++) cin >> a[i];
    int i = length - 1;

    for (int j = 0; j < k; j++)
    {
        i -= step;
        total += a[i];
        i--;
    }
    cout << total << endl;

}

int main()
{
    int t;
    cin >> t;
    while(t--) task();

    return 0;
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read()
{
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main()
{
	int t,n,k,a[20011];
	long long ans,nk;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		for(int i=1;i<=nk;i++)
		{
			cin>>a[i];
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read()
{
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main()
{
	int t,n,k,a[20011];
	int ans,nk;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		for(int i=1;i<=nk;i++)
		{
			cin>>a[i];
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int t,n,k,a[1011];
	int ans,nk;
	char s;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		s=getchar();
		for(int i=1;i<=nk;i++)
		{
			a[i]=0;
			do
			{
				s=getchar();
				//cout<<s<<' ';
				if(s!=' '&&s!='\n')
				{
					a[i]=a[i]*10+s-'0';
				}
			}while(s!=' '&&s!='\n');
			//cout<<endl;
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int t,n,k,a[1001],num;
	long long ans;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;
		for(int i=1;i<=n*k;i++)
		{
			cin>>a[i];
		}
		sort(a+1,a+n*k+1);
		num=n-(n+1)/2;
		for(int i=1;i<=k;i++)
		{
			ans+=a[n*k-i*num-i+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read()
{
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main()
{
	int t,n,k,a[200011],nk;
	long long ans;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		for(int i=1;i<=nk;i++)
		{
			a[i]=read();
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read()
{
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main()
{
	int t,n,k,a[1011];
	int ans,nk;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		for(int i=1;i<=nk;i++)
		{
			a[i]=read();
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read()
{
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main()
{
	int t,n,k,a[20011];
	int ans,nk;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		for(int i=1;i<=nk;i++)
		{
			a[i]=read();
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int t,n,k,a,m;
	int ans,nk;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;m=1;
		cin>>n>>k;nk=n*k;
		n=n-(n+1)/2+1;
		for(int i=k;i>=1;i--)
		{
			for(;m<=nk-n*i+1;m++)
			{
				cin>>a;
			}
			ans+=a;
		}
		for(;m<=nk;m++)
		{
			cin>>a;
		}
		cout<<ans<<endl;
	}
}


#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int t,n,k,a[1011];
	int ans,nk;
	cin>>t;
	for(int q=1;q<=t;q++)
	{
		ans=0;
		cin>>n>>k;nk=n*k;
		for(int i=1;i<=nk;i++)
		{
			cin>>a[i];
		}
		n=n-(n+1)/2+1;
		for(int i=1;i<=k;i++)
		{
			ans+=a[nk-i*n+1];
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 2e5 + 10;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        memset(a, 0, sizeof a);
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
        //sort(a + 1, a + n * k + 1);
        // for(int i = 1; i <= n * k; i ++ ) cout << a[i] << ' ';
        // cout << endl;

            if(n == 2)
            {
                for(int i = 1; i <= n * k; i += 2)
                {
                    sum += a[i];
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
        }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 1010;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
            if(n == 2)
            {
                int s = 1;
                for(int i = 1; i <= n * k; i += 2)
                {
                    if(n * k - s * 2 + 1 <= i)
                    {
                        if(n * k - s * 2 + 1 == i) sum += a[i];
                        break;
                    }
                    else sum += a[i] + a[n * k - s * 2 + 1];
                    s ++ ;
                }
            }
            else
            {
                int s = 1;
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    if(n * k - (n - 1) * s + 1 <= i)
                    {
                         if(n * k - (n - 1) * s + 1 == i) sum += a[i];
                    }
                    else sum += a[i] + a[n * k - (n - 1) * s + 1];
                    s ++ ;
                }
            }
            cout << sum << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 2e5 + 10;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        memset(a, 0, sizeof a);
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
        //sort(a + 1, a + n * k + 1);
        // for(int i = 1; i <= n * k; i ++ ) cout << a[i] << ' ';
        // cout << endl;
        if(n * k == 2 && n == 2) cout << a[1] << endl;
        else if(n * k == 2 && n == 1) cout << a[1] + a[2] << endl;
        else
        {
            if(n == 2)
            {
                for(int i = 1; i <= n * k; i += 2)
                {
                    sum += a[i];
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 1010;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
            if(n == 2)
            {
                for(int i = 1; i <= n * k; i += 2)
                {
                    sum += a[i];
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;
int a[N];

int main()
{
    int T;
    cin >> T;
    while(T -- )
    {
        memset(a, 0, sizeof a);
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        // for(int i = 1; i <= n * k; i ++ ) cout << a[i] << ' ';
        // cout << endl;
        if(n * k == 2 && n == 2) cout << a[1] << endl;
        else if(n * k == 2 && n == 1) cout << a[1] + a[2] << endl;
        else
        {
            if(n == 2)
            {
                int num = n;
                for(int i = 1; i <= k; i ++ )
                {
                    int t = n * k - num * i + 1;
                    //cout << t << endl;
                    sum += a[t];
                }
            }
            else
            {
                for(int i = k+1; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 1010;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
            if(n == 2)
            {
                int s = 1;
                for(int i = 1; i <= n * k; i += 2)
                {
                    if(n * k - s * 2 + 1 <= i)
                    {
                        if(n * k - s * 2 + 1 == i) sum += a[i];
                        break;
                    }
                    else sum += a[i] + a[n * k - s * 2 + 1];
                    s ++ ;
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 2e5 + 10;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        memset(a, 0, sizeof a);
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        // for(int i = 1; i <= n * k; i ++ ) cout << a[i] << ' ';
        // cout << endl;
        if(n * k == 2 && n == 2) cout << a[1] << endl;
        else if(n * k == 2 && n == 1) cout << a[1] + a[2] << endl;
        else
        {
            if(n == 2)
            {
                for(int i = 1; i <= n * k; i += 2)
                {
                    sum += a[i];
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 1010;
int a[N];

signed main()
{

    int T;
    scanf("%lld", &T);
    while(T -- )
    {
        int n, k;
        int sum = 0;
        scanf("%lld%lld", &n, &k);
        for(int i = 1; i <= n * k; i ++ )
        {
            scanf("%lld", &a[i]);
        }
            if(n == 2)
            {
                int s = 1;
                for(int i = 1; i <= n * k; i += 2)
                {
                    if(n * k - s * 2 + 1 <= i)
                    {
                        if(n * k - s * 2 + 1 == i) sum += a[i];
                        break;
                    }
                    else sum += a[i] + a[n * k - s * 2 + 1];
                    s ++ ;
                }
            }
            else
            {
                int s = 1;
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    if(n * k - (n - 1) * s + 1 <= i)
                    {
                         if(n * k - (n - 1) * s + 1 == i) sum += a[i];
                    }
                    else sum += a[i] + a[n * k - (n - 1) * s + 1];
                    s ++ ;
                }
            }
            printf("%lld\n", sum);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;
int a[N];

int main()
{
    int T;
    cin >> T;
    while(T -- )
    {
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        // for(int i = 1; i <= n * k; i ++ ) cout << a[i] << ' ';
        // cout << endl;
        if(n * k == 2 && n == 2) cout << a[1] << endl;
        else if(n * k == 2 && n == 1) cout << a[1] + a[2] << endl;
        else
        {
            int num = n - 1;
            if(n == 2) num = n;
            for(int i = 1; i <= k; i ++ )
            {
                int t = n * k - num * i + 1;
                //cout << t << endl;
                sum += a[t];
            }
            cout << sum << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 1010;
int a[N];

signed main()
{

    int T;
    scanf("%lld", &T);
    while(T -- )
    {
        int n, k;
        int sum = 0;
        scanf("%lld%lld", &n, &k);
        for(int i = 1; i <= n * k; i ++ )
        {
            scanf("%lld", &a[i]);
        }
            if(n == 1) for(int i = 1; i <= k; i ++ ) sum += a[i];
            else if(n == 2)
            {
                int s = 1;
                for(int i = 1; i <= n * k; i += 2)
                {
                    if(n * k - s * 2 + 1 <= i)
                    {
                        if(n * k - s * 2 + 1 == i) sum += a[i];
                        break;
                    }
                    else sum += a[i] + a[n * k - s * 2 + 1];
                    s ++ ;
                }
            }
            else
            {
                int s = 1;
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    if(n * k - (n - 1) * s + 1 <= i)
                    {
                         if(n * k - (n - 1) * s + 1 == i) sum += a[i];
                    }
                    else sum += a[i] + a[n * k - (n - 1) * s + 1];
                    s ++ ;
                }
            }
            printf("%lld\n", sum);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N = 1010;
int a[N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T -- )
    {
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
            if(n == 2)
            {
                for(int i = 1; i <= n * k; i += 2)
                {
                    if(n * k - i * 2 + 1 == i)
                    {
                        sum += a[i];
                        break;
                    }
                    else sum += a[i] + a[n * k - i * 2 + 1];
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;
int a[N];

int main()
{
    int T;
    cin >> T;
    while(T -- )
    {
        memset(a, 0, sizeof a);
        int n, k;
        int sum = 0;
        cin >> n >> k;
        for(int i = 1; i <= n * k; i ++ )
        {
            cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        // for(int i = 1; i <= n * k; i ++ ) cout << a[i] << ' ';
        // cout << endl;
        if(n * k == 2 && n == 2) cout << a[1] << endl;
        else if(n * k == 2 && n == 1) cout << a[1] + a[2] << endl;
        else
        {
            if(n == 2)
            {
                for(int i = 1; i <= n * k; i += 2)
                {
                    sum += a[i];
                }
            }
            else
            {
                for(int i = k+(n-1)/2; i <= n * k; i += n-1)
                {
                    sum += a[i];
                }
            }
            cout << sum << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N = 1e6 + 10;
int a[N];

signed main()
{
    int T;
    cin >> T;
    while(T -- )
    {
        int n, q;
        cin >> n >> q;
        for(int i = 1; i <= n * q; i ++ ) cin >> a[i];
        int t = n - (n + 1) / 2;
        int sum = 0;
        for(int i = n * q - t, j = 1; j <= q; j ++ , i -= t + 1)
        {
            sum += a[i];
        }
        cout << sum << endl;
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<set>
using namespace std;

int n,m,r,k;
long long ans;

const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};

int f(int x,int y){
	return (min(x+r-1,n)-max(r,x)+1)*(min(y+r-1,m)-max(r,y)+1);
}

struct node{
	int x,y;
	node(int x=0,int y=0):x(x),y(y){}
	bool operator < (const node& n)const{
		return f(x,y)<f(n.x,n.y);
	}
};

priority_queue<node> q;
set<int> s[100005];

void bfs(int x,int y){
	q.push(node(x,y));
	s[x].insert(y);
	int x1,y1,x2,y2;
	while(k--){
		x1=q.top().x; y1=q.top().y;
		ans+=f(x1,y1);
		q.pop();
		for(int i=0;i<4;i++){
			x2=x1+dx[i];
			y2=y1+dy[i];
			if(x2<=0||x2>n||y2<=0||y2>m||s[x2].count(y2)) continue;
			q.push(node(x2,y2));
			s[x2].insert(y2);
		}
	}
}

int main(){
	cin>>n>>m>>r>>k;
	bfs((n+1)/2,(m+1)/2);
	printf("%.9f",double(ans)/double(n-r+1)/double(m-r+1));
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long LL;

#ifdef LOCAL_JUDGE
template<class T>
inline void print1(T* a,int l,int r){
	for(int i=l;i<=r;i++) cout<<a[i]<<" ";
	cout<<endl;
}
template<class T>
inline void print2(T* a,int nn,int mm){
	for(int i=1;i<=nn;i++){
		for(int j=1;j<=mm;j++){
			cout<<a[i][j];
		}
		cout<<endl;
	}
}
#else
inline void print1(void *a,int l,int r){}
inline void print2(void* a,int nn,int mm){}
#endif

const int N=100000+5;
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};
int n,sx,sy,m,r,k;
double cx,cy;
LL cal(int x,int y){//ÔÚ(x,y)µã·ÅÏÂÒ»ÌõÓã»á±»ÀÌÆðÀ´µÄ´ÎÊý
    return (LL)(min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
struct Node{
	int x,y;
	LL d;
	Node(int x1=0,int y1=0):x(x1),y(y1){
		d=cal(x,y);
	}
	bool operator < (const Node &b)const{
		return d<b.d;
	}
};
priority_queue<Node> q;
map<pair<int,int>,bool > vis;
double sum1=0,sum2=0;

void bfs(){
	int cnt=0;
	q.push(Node(sx,sy));
	vis[make_pair(sx,sy)]=1;
	while(!q.empty()){
		Node cur=q.top();q.pop();
		cnt++;
		sum1+=cur.d;
		if(cnt==k)  break;
		for(int i=0;i<4;i++){
			int xi=cur.x+dx[i];
			int yi=cur.y+dy[i];
			if(xi>=1&&xi<=n&&yi>=1&&yi<=m&&vis[make_pair(xi,yi)]==0){
				vis[make_pair(xi,yi)]=1;
				q.push(Node(xi,yi));
			}
		}
	}
}
int main(){
	#ifdef LOCAL_JUDGE
//		freopen("","r",stdin);
	#endif
	cin>>n>>m>>r>>k;
	cx=(1.0+n)/2;
	cy=(1.0+m)/2;
	sx=(1+n)/2;
	sy=(1+m)/2;
	bfs();
	sum2=(LL)(n-r+1)*(m-r+1);
	printf("%.10f\n",sum1/sum2);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Node{
	long long int x,y,cnt;
	Node(long long int i=0,long long int j=0,long long int k=0){
		x=i;y=j;cnt=k;
	}
	friend bool operator <(const Node &a,const Node &b){
		return a.cnt<b.cnt;
	}
};
long long int n,m,r,k;
long long ans;
int d[10]={0,1,0,-1,0};
string s;
priority_queue <Node> q;
map <string,bool> v;
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
void bfs(long long int sx,long long int sy){
	s.clear();s+=sx;s+=sy;v[s]=true;
	q.push(Node(sx,sy,cal(sx,sy)));
	for(int j=1;j<=k;j++)
	{
		Node cur=q.top();q.pop();
		ans+=cur.cnt;
		for(int i=0;i<4;i++){
			long long int nx=cur.x+d[i];
			long long int ny=cur.y+d[i+1];
			s.clear();s+=nx;s+=ny;
			if(nx<1||nx>n||ny<1||ny>m||v[s]) continue;
			v[s]=true;
			q.push(Node(nx,ny,cal(nx,ny)));
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&k);
	long double tot=(n-r+1)*(m-r+1);
	bfs((n+1)/2,(m+1)/2);
	cout<<fixed<<setprecision(10)<<ans/tot<<endl;
	return 0;
}


# include <cstdio>
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstring>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <ctime>
# include <cstdlib>

# define f(i,a,b) for (int i = a; i <= b; i++)
# define _f(i,a,b) for (int i = a; i >= b; i--)
# define TS cout << "!!!!" << endl
using namespace std;

const int NR = 1e5 + 1000;
const int inf = 1e9;
const int mov[5][2] = {{0, 0}, {0, 1}, {0, -1}, {1, 0}, {-1, 0}};

long long n, m, r;
int k;

long long cal(long long x, long long y) {
    return (min(n, x + r - 1) - max(x, r) + 1) * (min(m, y + r - 1) - max(y, r) + 1);
}

struct Node {
    long long x, y, z;

    bool operator < (const Node &b) const {
        return z < b.z;
    }

};
priority_queue <Node> q;
map <pair<long long, long long>, bool> flag;

int main() {
    scanf("%lld%lld%lld%d", &n, &m, &r, &k);
    long long x1 = (n + 1) >> 1, y1 = (m + 1) >> 1;
    q.push((Node) {x1, y1, cal(x1, y1)});
    flag[make_pair(x1, y1)] = true;
    long long sum = 0;
    f(kkk,1,k) {
        Node x = q.top();
        q.pop();
        sum += x.z;
        f(i,1,4) {
            long long tx = x.x + mov[i][0];
            long long ty = x.y + mov[i][1];
            if (tx < 1 || tx > n || ty < 1 || ty > m || flag[make_pair(tx, ty)]) continue;
            flag[make_pair(tx, ty)] = true;
            q.push((Node) {tx, ty, cal(tx, ty)});
        }
    }
    long long tot = (n - r + 1) * (m - r + 1);
    printf("%f\n", sum * 1.0 / tot);
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<cstdio>
#define MAXN 200005
#define LL long long
using namespace std;
LL n,m,r,k,dx[4]={0,1,-1,0},dy[4]={1,0,0,-1};
LL f(LL x,LL y){
	return (min(x+r-1,n)-max(x,r))*(min(y+r-1,m)-max(y,r));
}
double ans=0;
struct node{
	LL x,y;
	node(LL ax,LL ay){
		x=ax;
		y=ay;
	}
	node(){
	}
	bool operator <(const node &e)const{
		return f(x,y)<f(e.x,e.y);
	}
};
set<LL> vis[MAXN];
priority_queue<node> q;
int main(){
	cin>>n>>m>>r>>k;
	q.push(node((n+1)/2,(m+1)/2));
	vis[(n+1)/2].insert((m+1)/2);
	for(LL u=1;u<=k;u++){
		LL x0=q.top().x,y0=q.top().y;
		cout<<x0<<" "<<y0<<" "<<f(x0,y0)<<endl;
		ans+=f(x0,y0);
		q.pop();
		for(LL i=0;i<4;i++){
			LL x1=x0+dx[i],y1=y0+dy[i];
			if(vis[x1].count(y1)){
				continue;
			}
			vis[x1].insert(y1);
			q.push(node(x1,y1));
		}
	}
	ans/=double((n-r+1)*(m-r+1));
	printf("%.9f",ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dx[10]={0,1,0,-1,0},dy[10]={0,0,1,0,-1};
int n,m,k,r;
ll ans;
double all;
struct node
{
	ll cnt;
	int x,y;
};
bool operator <(node a,node b)
{
	return a.cnt<b.cnt;
}
priority_queue<node>q;
map<pair<int,int>,bool> mp;
ll calc(int x,int y)
{
	return 1ll*(min(n,x+r-1)-max(r,x)+1)*(min(m,y+r-1)-max(r,y)+1);
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&r,&k);
	all=(n-r+1)*(m-r+1);
	int cx=(n+1)/2,cy=(m+1)/2;
	q.push(node{calc(cx,cy),cx,cy});
	mp[make_pair(cx,cy)]=true;
	while(k--)
	{
		node now=q.top();
		q.pop();
		ans+=now.cnt;
		for(int i=1;i<=4;i++)
		{
			if(now.x+dx[i]>n||now.x+dx[i]<1||now.y+dy[i]>m||now.y+dy[i]<1||mp[make_pair(now.x+dx[i],now.y+dy[i])]==true) continue;
			q.push(node{calc(now.x+dx[i],now.y+dy[i]),now.x+dx[i],now.y+dy[i]});
			mp[make_pair(now.x+dx[i],now.y+dy[i])]=true;
		}
	}
	printf("%.9lf",ans/all);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Node{
	long long int x,y,cnt;
	Node(long long int i=0,long long int j=0,long long int k=0){
		x=i;y=j;cnt=k;
	}
	friend bool operator <(const Node &a,const Node &b){
		return a.cnt<b.cnt;
	}
};
long long int n,m,r,k;
double ans;
int d[10]={0,1,0,-1,0};
string s;
priority_queue <Node> q;
map <string,bool> v;
void bfs(long long int sx,long long int sy){
	s.clear();
	s+=sx;s+=sy;v[s]=true;
	q.push(Node(sx,sy,(min(n,sx+r-1)-max(sx,r)+1)*(min(m,sy+r-1)-max(sy,r)+1)));
	while(!q.empty()){
		Node cur=q.top();q.pop();
		ans+=cur.cnt;k--;
		if(k==0) return;
		for(int i=0;i<4;i++){
			long long int nx=cur.x+d[i];
			long long int ny=cur.y+d[i+1];
			if(nx<1||nx>n||ny<1||ny>m) continue;
			s.clear();
			s+=nx;s+=ny;
			if(!v[s]){
				v[s]=true;
				q.push(Node(nx,ny,(min(n,nx+r-1)-max(nx,r)+1)*(min(m,ny+r-1)-max(ny,r)+1)));
			}
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&k);
	double tot=(n-r+1)*(m-r+1);
	bfs((n+1)/2,(m+1)/2);
	printf("%.10f",ans/tot);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

const int MAXN = 1e5 + 5;

typedef long double lf;
typedef long long ll;
typedef pair<int, int> point;

unordered_map<ll, bool> bio;

int n, m, r, k;

lf sol;

int x1, x2, y1, y2;

lf add(int x, int y) {

  int X = r;
  X -= max(0, r - (x + 1));
  X -= max(0, r - (m - x));

  int Y = r;
  Y -= max(0, r - (y + 1));
  Y -= max(0, r - (n - y));

  return (lf) X * Y / ((lf) (n - r + 1) * (m - r + 1));
}

ll f(int i, int j) {
  return (ll) i * MAXN + j;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

set<pair<lf, point>> S;

void solve() {
  x1 = min(r - 1, (m - 1) / 2);
  y1 = min(r - 1, (n - 1) / 2);

  x2 = m - x1 - 1;
  y2 = n - y1 - 1;

  FOR(i, x1, x2 + 1) FOR(j, y1, y2 + 1) {
    S.insert({-1, {i, j}});
    bio[f(i, j)] = true;
  }

  while(k --) {
    auto it = S.begin();

    int x = (*it).second.first;
    int y = (*it).second.second;

    S.erase(S.begin());

    REP(k, 4) {
      int nx = x + dx[k];
      int ny = y + dy[k];

      if(nx >= 0 && ny >= 0 && nx < m && ny < n && !bio[f(nx, ny)]) {
        S.insert({-add(nx, ny), {nx, ny}});
        bio[f(nx, ny)] = true;
      }
    }

    sol += add(x, y);
  }
}

int main() {
  cin >> n >> m >> r >> k;

  solve();
  cout << fixed << setprecision(10) << sol << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

const int MAXN = 1e5 + 5;

typedef long double lf;
typedef long long ll;
typedef pair<int, int> point;

unordered_map<ll, bool> bio;

int n, m, r, k;

lf sol;

int x1, x2, y1, y2;

lf add(int x, int y) {

  int X = r;
  X -= max(0, r - (x + 1));
  X -= max(0, r - (m - x));

  int Y = r;
  Y -= max(0, r - (y + 1));
  Y -= max(0, r - (n - y));

  return (lf) X * Y / ((lf) (n - r + 1) * (m - r + 1));
}

ll f(int i, int j) {
  return (ll) i * MAXN + j;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

set<pair<lf, point>> S;

void solve() {
  x1 = min(r - 1, (m - 1) / 2);
  y1 = min(r - 1, (n - 1) / 2);

  x2 = m - x1 - 1;
  y2 = n - y1 - 1;

  int br = 0;

  FOR(i, x1, x2 + 1) FOR(j, y1, y2 + 1) {
    br ++;
    if(br > k) break;
    S.insert({-1, {i, j}});
    bio[f(i, j)] = true;
  }

  while(k --) {
    auto it = S.begin();

    int x = (*it).second.first;
    int y = (*it).second.second;

    S.erase(S.begin());

    REP(k, 4) {
      int nx = x + dx[k];
      int ny = y + dy[k];

      if(nx >= 0 && ny >= 0 && nx < m && ny < n && !bio[f(nx, ny)]) {
        S.insert({-add(nx, ny), {nx, ny}});
        bio[f(nx, ny)] = true;
      }
    }

    sol += add(x, y);
  }
}

int main() {
  cin >> n >> m >> r >> k;

  solve();
  cout << fixed << setprecision(10) << sol << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

const int MAXN = 1e5 + 5;

typedef long double lf;
typedef long long ll;
typedef pair<int, int> point;

unordered_map<ll, bool> bio;

int n, m, r, k;

lf sol;

int x1, x2, y1, y2;

lf add(int x, int y) {

  int X = r;
  X -= max(0, r - (x + 1));
  X -= max(0, r - (m - x));

  int Y = r;
  Y -= max(0, r - (y + 1));
  Y -= max(0, r - (n - y));

  return (lf) X * Y / ((lf) (n - r + 1) * (m - r + 1));
}

ll f(int i, int j) {
  return (ll) i * MAXN + j;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

set<pair<lf, point>> S;

void solve() {
  x1 = min(r - 1, (m - 1) / 2);
  y1 = min(r - 1, (n - 1) / 2);

  x2 = m - x1 - 1;
  y2 = n - y1 - 1;

  FOR(i, x1, x2 + 1) FOR(j, y1, y2 + 1) {
    S.insert({-1, {i, j}});
    bio[f(i, j)] = true;
  }

  while(k --) {
    auto it = S.begin();

    int x = (*it).second.first;
    int y = (*it).second.second;

    S.erase(S.begin());

    if(S.size() >= 2 * k) {
      sol += add(x, y);
      continue;
    }

    REP(k, 4) {
      int nx = x + dx[k];
      int ny = y + dy[k];

      if(nx >= 0 && ny >= 0 && nx < m && ny < n && !bio[f(nx, ny)]) {
        S.insert({-add(nx, ny), {nx, ny}});
        bio[f(nx, ny)] = true;
      }
    }

    sol += add(x, y);
  }
}

int main() {
  cin >> n >> m >> r >> k;

  solve();
  cout << fixed << setprecision(10) << sol << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 +10;
ll n, m, r, k;
struct Tpoint{
    int x, y;
    Tpoint(int x = 0, int y = 0):x(x),y(y){}
    bool operator < (const Tpoint asd) const{
        return 1LL * x * y < 1LL * asd.x *asd.y;
    }
};
map<Tpoint, bool> mp;
priority_queue<Tpoint> p;
int a[maxn], b[maxn];
int num1[maxn], num2[maxn];
int main(){
    cin >>n >>m >>r >>k;
    for (int i = 1; i <= n; i ++)
        if (i +r - 1 <= n) a[i] ++, a[i + r] --;
    for (int i = 1; i <= m; i ++)
        if (i +r - 1<= m) b[i]++, b[i +r] --;
    int tmp = 0, stx = 0, sty = 0;
    for (int i = 1; i <= n; i ++){
        tmp += a[i], num1[tmp] ++;
        stx = max(stx, tmp);
    }
    tmp = 0;
    for (int i = 1; i <= m; i ++){
        tmp += b[i], num2[tmp] ++;
        sty = max(sty, tmp);
    }
    p.push(Tpoint(stx, sty));
    mp[Tpoint(stx, sty)] = 1;
    ll ans = 0;
    while (k > 0){
        Tpoint qq = p.top();
        p.pop();
        Tpoint asd = qq;
        if (asd.x > 1){
            asd.x --;
            if (!mp[asd]) p.push(asd);
        }
        asd = qq;
        if (asd.y > 1){
            asd.y --;
            if (!mp[asd]) p.push(asd);
        }

        ll num = 1LL * num1[qq.x] * num2[qq.y];
        num = min(num, k);
        k -= num;
        ans += 1LL * num * qq.x * qq.y;
      //  cout <<qq.x <<' ' <<qq.y <<' ' <<num <<' ' <<ans <<endl;
    }
    printf("%.10f\n", 1.0 * ans / (1LL * (n - r +1) * (m-r+1)));
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 +10;
ll n, m, r, k;
struct Tpoint{
    int x, y;
    Tpoint(int x = 0, int y = 0):x(x),y(y){}
    bool operator < (const Tpoint asd) const{
        return 1LL * x * y < 1LL * asd.x *asd.y;
    }
};
map<Tpoint, bool> mp;
priority_queue<Tpoint> p;
int a[maxn], b[maxn];
int num1[maxn], num2[maxn];
int main(){
    cin >>n >>m >>r >>k;
    for (int i = 1; i <= n; i ++)
        if (i +r - 1 <= n) a[i] ++, a[i + r] --;
    for (int i = 1; i <= m; i ++)
        if (i +r - 1<= m) b[i]++, b[i +r] --;
    int tmp = 0, stx = 0, sty = 0;
    for (int i = 1; i <= n; i ++){
        tmp += a[i], num1[tmp] ++;
        stx = max(stx, tmp);
    }
    tmp = 0;
    for (int i = 1; i <= m; i ++){
        tmp += b[i], num2[tmp] ++;
        sty = max(sty, tmp);
    }
    p.push(Tpoint(stx, sty));
    mp[Tpoint(stx, sty)] = 1;
    ll ans = 0;
    while (k > 0){
        Tpoint qq = p.top();
        p.pop();
        Tpoint asd = qq;
        if (asd.x > 1){
            asd.x --;
            if (!mp[asd]) p.push(asd);
        }
        asd = qq;
        if (asd.y > 1){
            asd.y --;
            if (!mp[asd]) p.push(asd);
        }

        ll num = 1LL * num1[qq.x] * num2[qq.y];
        num = min(num, k);
        k -= num;
        ans += 1LL * num * qq.x * qq.y;
      //  cout <<qq.x <<' ' <<qq.y <<' ' <<num <<' ' <<ans <<endl;
    }
    printf("%.8f\n", 1.0 * ans / (1LL * (n - r +1) * (m-r+1)));
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 +10;
ll n, m, r, k;
struct Tpoint{
    int x, y;
    Tpoint(int x = 0, int y = 0):x(x),y(y){}
    bool operator < (const Tpoint asd) const{
        if ( 1LL * x * y != 1LL * asd.x *asd.y)
        return 1LL * x * y < 1LL * asd.x *asd.y;
        else {
            if (x != asd.x)return x <asd.x;
            else return y < asd.y;
        }
    }
};
map<Tpoint, bool> mp;
priority_queue<Tpoint> p;
int a[maxn], b[maxn];
int num1[maxn], num2[maxn];
int main(){
    cin >>n >>m >>r >>k;
    for (int i = 1; i <= n; i ++)
        if (i +r - 1 <= n) a[i] ++, a[i + r] --;
    for (int i = 1; i <= m; i ++)
        if (i +r - 1<= m) b[i]++, b[i +r] --;
    int tmp = 0, stx = 0, sty = 0;
    for (int i = 1; i <= n; i ++){
        tmp += a[i], num1[tmp] ++;
        stx = max(stx, tmp);
    }
    tmp = 0;
    for (int i = 1; i <= m; i ++){
        tmp += b[i], num2[tmp] ++;
        sty = max(sty, tmp);
    }
    p.push(Tpoint(stx, sty));
    mp[Tpoint(stx, sty)] = 1;
    ll ans = 0;
    while (k > 0){
        Tpoint qq = p.top();
        p.pop();
        Tpoint asd = qq;
        if (asd.x > 1){
            asd.x --;
            if (!mp[asd])p.push(asd), mp[asd] = 1;
        }
        asd = qq;
        if (asd.y > 1){
            asd.y --;
            if (!mp[asd]) p.push(asd), mp[asd] = 1;
        }

        ll num = 1LL * num1[qq.x] * num2[qq.y];
        num = min(num, k);
        k -= num;
        ans += 1LL * num * qq.x * qq.y;
     }
    printf("%.10f\n", 1.0 * ans / (1LL * (n - r +1) * (m-r+1)));
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , r , k , p[N] ;
ld a[N] , b[N] , ans , di ;
priority_queue <pair <ld , int>> st ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m >> r >> k ;

	for (int i = 0 ; i < n ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , n - r) ;
		a[i] = high - low + 1 ;
	}
	for (int i = 0 ; i < m ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , m - r) ;
		b[i] = high - low + 1 ;
	}

	di = (n - r + 1) * (m - r + 1) ;

	sort(a , a + n , greater <int>()) ;
	sort(b , b + m , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		p[i] = 0 ;
		st.push({a[i] * b[p[i]] , i}) ;
	}

	while (k --) {
		int i = st.top().S ;
		st.pop();

		ans += (ld)a[i] * b[p[i]] ;
		p[i] ++ ;

		if (p[i] < m) {
			st.push({a[i] * b[p[i]] , i}) ;
		}
	}

	cout << fixed << setprecision(50) << (ld)ans / di << '\n' ;
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , r , k , a[N] , b[N] , p[N] ;
int ans , di ;
set <pii> st ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m >> r >> k ;

	for (int i = 0 ; i < n ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , m - r) ;
		a[i] = high - low + 1 ;
	}
	for (int i = 0 ; i < m ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , n - r) ;
		b[i] = high - low + 1 ;
	}

	di = (n - r + 1) * (m - r + 1) ;

	sort(a , a + n , greater <int>()) ;
	sort(b , b + m , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		p[i] = 0 ;
		st.insert({-a[i] * b[p[i]] , i}) ;
	}

	while (k --) {
		int i = st.begin() -> S ;
		st.erase(st.begin()) ;

		ans += (ld)a[i] * b[p[i]] ;
		p[i] ++ ;

		if (p[i] < m) {
			st.insert({-a[i] * b[p[i]] , i}) ;
		}
	}

	cout << fixed << setprecision(50) << (ld)ans / di << '\n' ;
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , r , k , a[N] , b[N] , p[N] ;
int ans , di ;
set <pii> st ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m >> r >> k ;

	for (int i = 0 ; i < n ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , m - r) ;
		a[i] = high - low + 1 ;
	}
	for (int i = 0 ; i < m ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , n - r) ;
		b[i] = high - low + 1 ;
	}

	di = (n - r + 1) * (m - r + 1) ;

	sort(a , a + n , greater <int>()) ;
	sort(b , b + m , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		p[i] = 0 ;
		st.insert({-a[i] * b[p[i]] , i}) ;
	}

	while (k --) {
		int i = st.begin() -> S ;
		st.erase(st.begin()) ;

		ans += (ld)a[i] * b[p[i]] ;
		p[i] ++ ;

		if (p[i] < m) {
			st.insert({-a[i] * b[p[i]] , i}) ;
		}
	}

	cout << fixed << setprecision(20) << (ld)ans / di << '\n' ;
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , r , k , p[N] ;
ld a[N] , b[N] , ans , di ;
priority_queue <pair <ld , int>> st ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m >> r >> k ;

	for (int i = 0 ; i < n ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , m - r) ;
		a[i] = high - low + 1 ;
	}
	for (int i = 0 ; i < m ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , n - r) ;
		b[i] = high - low + 1 ;
	}

	di = (n - r + 1) * (m - r + 1) ;

	sort(a , a + n , greater <int>()) ;
	sort(b , b + m , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		p[i] = 0 ;
		st.push({a[i] * b[p[i]] , i}) ;
	}

	while (k --) {
		int i = st.top().S ;
		st.pop();

		ans += (ld)a[i] * b[p[i]] ;
		p[i] ++ ;

		if (p[i] < m) {
			st.push({a[i] * b[p[i]] , i}) ;
		}
	}

	cout << fixed << setprecision(50) << (ld)ans / di << '\n' ;
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , r , k , a[N] , b[N] , p[N] ;
ld ans , di ;
set <pii> st ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m >> r >> k ;

	for (int i = 0 ; i < n ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , m - r) ;
		a[i] = high - low + 1 ;
	}
	for (int i = 0 ; i < m ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , n - r) ;
		b[i] = high - low + 1 ;
	}

	di = (n - r + 1) * (m - r + 1) ;

	sort(a , a + n , greater <int>()) ;
	sort(b , b + m , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		p[i] = 0 ;
		st.insert({-a[i] * b[p[i]] , i}) ;
	}

	while (k --) {
		int i = st.begin() -> S ;
		st.erase(st.begin()) ;

		ans += (ld)a[i] * b[p[i] ++] / di ;

		if (p[i] < m) {
			st.insert({-a[i] * b[p[i]] , i}) ;
		}
	}

	cout << fixed << setprecision(10) << ans << '\n' ;
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , r , k , a[N] , b[N] , p[N] ;
int ans , di ;
set <pii> st ;

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m >> r >> k ;

	for (int i = 0 ; i < n ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , m - r) ;
		a[i] = high - low + 1 ;
	}
	for (int i = 0 ; i < m ; i ++) {
		int low = max(0ll , i - r + 1) ;
		int high = min(i , n - r) ;
		b[i] = high - low + 1 ;
	}

	di = (n - r + 1) * (m - r + 1) ;

	sort(a , a + n , greater <int>()) ;
	sort(b , b + m , greater <int>()) ;

	for (int i = 0 ; i < n ; i ++) {
		p[i] = 0 ;
		st.insert({-a[i] * b[p[i]] , i}) ;
	}

	while (k --) {
		int i = st.begin() -> S ;
		st.erase(st.begin()) ;

		ans += (ld)a[i] * b[p[i] ++] ;

		if (p[i] < m) {
			st.insert({-a[i] * b[p[i]] , i}) ;
		}
	}

	cout << fixed << setprecision(15) << (ld)ans / di << '\n' ;
}


#include <iostream>
#include <vector>
#include <tuple>
#include <unordered_set>
#include <queue>
#include <algorithm>

using namespace std;
int n, m, r, k;

long long encode(int x, int y) {
    return (long long)x * 1e6 + y;
}

long long get_freq(int i, int j) {
    long long xlo = max(0, i-r+1), xhi = min(i, n-r);
    long long ylo = max(0, j-r+1), yhi = min(j, m-r);
    return max(0ll, xhi-xlo+1) * max(0ll, yhi-ylo+1);
}

vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {

    ios::sync_with_stdio(false);

    cin >> n >> m >> r >> k;

    priority_queue<tuple<long long,int,int>> q;
    q.push({get_freq(n/2, m/2), n/2, m/2});

    double sum = 0;
    int count = 0;
    unordered_set<long long> vis;
    vis.insert(encode(n/2, m/2));

    for (int x, y; !q.empty() && count<k; ++count) {
        long long freq;
        tie(freq, x, y) = q.top();
        // cout << x << ' ' << y << ' ' << freq << endl;
        q.pop();

        sum += freq;

        for (int dir=0; dir<4; ++dir) {
            int tx = x+dx[dir], ty = y+dy[dir];
            int ind = encode(tx, ty);
            if (tx>=0 && tx<n && ty>=0 && ty<m && vis.find(ind)==vis.end()) {
                vis.insert(ind);
                q.push({get_freq(tx, ty), tx, ty});
            }
        }
    }

    cout.precision(10);
    cout << fixed << sum / ((n-r+1)*(m-r+1)) << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <tuple>
#include <unordered_set>
#include <queue>
#include <algorithm>

using namespace std;
int n, m, r, k;

using TLLII = tuple<long long, int ,int>;

long long encode(int x, int y) {
    return (long long)x * 1e6 + y;
}

long long get_freq(int i, int j) {
    long long xlo = max(0, i-r+1), xhi = min(i, n-r);
    long long ylo = max(0, j-r+1), yhi = min(j, m-r);
    return max(0ll, xhi-xlo+1) * max(0ll, yhi-ylo+1);
}

vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {

    ios::sync_with_stdio(false);

    cin >> n >> m >> r >> k;

    priority_queue<TLLII> q;
    q.push(TLLII(get_freq(n/2, m/2), n/2, m/2));

    double sum = 0;
    int count = 0;
    unordered_set<long long> vis;
    vis.insert(encode(n/2, m/2));

    for (int x, y; !q.empty() && count<k; ++count) {
        long long freq;
        tie(freq, x, y) = q.top();
        // cout << x << ' ' << y << ' ' << freq << endl;
        q.pop();

        sum += freq;

        for (int dir=0; dir<4; ++dir) {
            int tx = x+dx[dir], ty = y+dy[dir];
            int ind = encode(tx, ty);
            if (tx>=0 && tx<n && ty>=0 && ty<m && vis.find(ind)==vis.end()) {
                vis.insert(ind);
                q.push(TLLII(get_freq(tx, ty), tx, ty));
            }
        }
    }

    cout.precision(10);
    cout << fixed << sum / ((n-r+1)*(m-r+1)) << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <tuple>
#include <unordered_set>
#include <queue>
#include <algorithm>

using namespace std;
int n, m, r, k;

using TLLII = tuple<long long, int ,int>;

long long encode(int x, int y) {
    return (long long)x * 1e6 + y;
}

long long get_freq(int i, int j) {
    long long xlo = max(0, i-r+1), xhi = min(i, n-r);
    long long ylo = max(0, j-r+1), yhi = min(j, m-r);
    return max(0ll, xhi-xlo+1) * max(0ll, yhi-ylo+1);
}

vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {

    ios::sync_with_stdio(false);

    cin >> n >> m >> r >> k;

    priority_queue<TLLII> q;
    q.push(TLLII(get_freq(n/2, m/2), n/2, m/2));

    double sum = 0;
    int count = 0;
    unordered_set<long long> vis;
    vis.insert(encode(n/2, m/2));
    for (int x, y; !q.empty() && count<k; ++count) {
        long long freq;
        tie(freq, x, y) = q.top();
        q.pop();

        sum += freq;

        for (int dir=0; dir<4; ++dir) {
            int tx = x+dx[dir], ty = y+dy[dir];
            long long ind = encode(tx, ty);
            if (tx>=0 && tx<n && ty>=0 && ty<m && vis.find(ind)==vis.end()) {
                vis.insert(ind);
                q.push(TLLII(get_freq(tx, ty), tx, ty));
            }
        }
    }

    cout.precision(10);
    cout << fixed << sum / ((long long)(n-r+1)*(m-r+1)) << endl;
    return 0;
}


#include <map>
#include <stack>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
long long n,m,r,k;
int xx[]={0,-1,0,1};
int yy[]={-1,0,1,0};
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
struct node{
    int x,y;
    long long val;
    friend bool operator<(node a,node b){
        return a.val<b.val;
    }
};
map<pair<int,int>,bool> mp;
long long bfs(){
    node tmp;
    long long ans;
    int i,tmpx,tmpy;
    priority_queue<node> qu;
    ans=0,tmpx=(n+1)/2,tmpy=(m+1)/2;
    qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
    mp[make_pair(tmpx,tmpy)]=1;
    while(qu.size()){
        tmp=qu.top();
        qu.pop();
        k--;
        ans+=tmp.val;
        if(k==0)
        return ans;
        for(i=0;i<4;i++){
            tmpx=tmp.x+xx[i];
            tmpy=tmp.y+yy[i];
            if(mp[make_pair(tmpx,tmpy)]==1)
            continue;
            if(tmpx<1||tmpx>n||tmpy<1||tmpy>m)
            continue;
            mp[make_pair(tmpx,tmpy)]=1;
            qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
        }
    }
    return ans;
}
int main(){
    double ans;
    while(cin>>n>>m>>r>>k){
        mp.clear();
        ans=(n-r+1)*(m-r+1);
        printf("%.12f\n",bfs()*1.0/ans);
    }
    return 0;
}


#include <map>
#include <stack>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
long long n,m,r,k;
int xx[]={0,-1,0,1};
int yy[]={-1,0,1,0};
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
struct node{
    int x,y;
    long long val;
    friend bool operator<(node a,node b){
        return a.val<b.val;
    }
};
map<pair<int,int>,bool> mp;
long long bfs(){
    node tmp;
    long long ans;
    int i,tmpx,tmpy;
    priority_queue<node> qu;
    ans=0,tmpx=(n+1)/2,tmpy=(m+1)/2;
    qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
    mp[make_pair(tmpx,tmpy)]=1;
    while(qu.size()){
        tmp=qu.top();
        qu.pop();
        k--;
        ans+=tmp.val;
        if(k==0)
        return ans;
        for(i=0;i<4;i++){
            tmpx=tmp.x+xx[i];
            tmpy=tmp.y+yy[i];
            if(mp[make_pair(tmpx,tmpy)]==1)
            continue;
            if(tmpx<1||tmpx>n||tmpy<1||tmpy>m)
            continue;
            mp[make_pair(tmpx,tmpy)]=1;
            qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
        }
    }
    return ans;
}
int main(){
    double ans;
    while(cin>>n>>m>>r>>k){
        mp.clear();
        ans=(n-r+1)*(m-r+1);
        cout<<ans<<endl;
        printf("%.12f\n",bfs()*1.0/ans);
    }
    return 0;
}


#include <map>
#include <stack>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
long long n,m,r,k;
long long xx[]={0,-1,0,1};
long long yy[]={-1,0,1,0};
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
struct node{
    long long x,y;
    long long val;
    friend bool operator<(node a,node b){
        return a.val<b.val;
    }
};
map<pair<long long,long long>,bool> mp;
long long bfs(){
    node tmp;
    long long ans;
    long long i,tmpx,tmpy;
    priority_queue<node> qu;
    ans=0,tmpx=(n+1)/2,tmpy=(m+1)/2;
    qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
    mp[make_pair(tmpx,tmpy)]=1;
    while(qu.size()){
        tmp=qu.top();
        qu.pop();
        k--;
        ans+=tmp.val;
        if(k==0)
        return ans;
        for(i=0;i<4;i++){
            tmpx=tmp.x+xx[i];
            tmpy=tmp.y+yy[i];
            if(mp[make_pair(tmpx,tmpy)]==1)
            continue;
            if(tmpx<1||tmpx>n||tmpy<1||tmpy>m)
            continue;
            mp[make_pair(tmpx,tmpy)]=1;
            qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
        }
    }
}
int main(){
    long long ans;
    while(cin>>n>>m>>r>>k){
        mp.clear();
        ans=(n-r+1)*(m-r+1);
        printf("%.10lf\n",bfs()*1.0/ans);
    }
    return 0;
}


#include <map>
#include <stack>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
long long n,m,r,k;
long long xx[]={0,-1,0,1};
long long yy[]={-1,0,1,0};
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
struct node{
    long long x,y;
    long long val;
    friend bool operator<(node a,node b){
        return a.val<b.val;
    }
};
map<pair<long long,long long>,bool> mp;
long long bfs(){
    node tmp;
    long long ans;
    long long i,tmpx,tmpy;
    priority_queue<node> qu;
    ans=0,tmpx=(n+1)/2,tmpy=(m+1)/2;
    qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
    mp[make_pair(tmpx,tmpy)]=1;
    while(qu.size()){
        tmp=qu.top();
        qu.pop();
        k--;
        ans+=tmp.val;
        if(k==0)
        return ans;
        for(i=0;i<4;i++){
            tmpx=tmp.x+xx[i];
            tmpy=tmp.y+yy[i];
            if(mp[make_pair(tmpx,tmpy)]==1)
            continue;
            if(tmpx<1||tmpx>n||tmpy<1||tmpy>m)
            continue;
            mp[make_pair(tmpx,tmpy)]=1;
            qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
        }
    }
}
int main(){
    long long ans;
    while(scanf("%I64d%I64d%I64d%I64d",&n,&m,&r,&k)!=EOF){
        mp.clear();
        ans=(n-r+1)*(m-r+1);
        printf("%.10lf\n",bfs()*1.0/ans);
    }
    return 0;
}


#include <map>
#include <stack>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,r,k;
int xx[]={0,-1,0,1};
int yy[]={-1,0,1,0};
long long cal(int x,int y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
struct node{
    int x,y;
    long long val;
    friend bool operator<(node a,node b){
        return a.val<b.val;
    }
};
map<pair<int,int>,bool> mp;
long long bfs(){
    node tmp;
    long long ans;
    int i,tmpx,tmpy;
    priority_queue<node> qu;
    ans=0,tmpx=(n+1)/2,tmpy=(m+1)/2;
    qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
    mp[make_pair(tmpx,tmpy)]=1;
    while(qu.size()){
        tmp=qu.top();
        qu.pop();
        k--;
        ans+=tmp.val;
        if(k==0)
        return ans;
        for(i=0;i<4;i++){
            tmpx=tmp.x+xx[i];
            tmpy=tmp.y+yy[i];
            if(mp[make_pair(tmpx,tmpy)]==1)
            continue;
            if(tmpx<1||tmpx>n||tmpy<1||tmpy>m)
            continue;
            mp[make_pair(tmpx,tmpy)]=1;
            qu.push((node){tmpx,tmpy,cal(tmpx,tmpy)});
        }
    }
}
int main(){
    long long ans;
    while(cin>>n>>m>>r>>k){
        mp.clear();
        ans=(n-r+1)*(m-r+1);
        printf("%.10lf\n",bfs()*1.0/ans);
    }
    return 0;
}


#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int t[100][100];
const int INF=1000000000;
map<P,bool>s;
int n,m,r,k;//n*m,rはあみの範囲、k引き
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
inline int di(int y,int x){
		int sy=r,sx=r;

	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	return y+x;
}

inline int culc(int y,int x){
	int sy=r,sx=r;

	//sy=min(y+1,n-y);
	//sx=min(x+1,m-x);
	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	if(x+r>m)sx-=x+r-m;
//cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=min(r,sy)*min(r,sx);
	return solve;
	/*
	cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=r*sy+r*sx;*/

}
int main(){
	cin>>n>>m>>r>>k;
	int midy,midx;
	midy=n/2;
	midx=m/2;

	priority_queue<pair<int,P> >bfs;
	bfs.push(mp(culc(midy,midx),mp(midy,midx)));

	s[mp(midy,midx)]=true;
	__int64 cnt=0,sum=0;
	int ii=0;
	//int ma=culc(midy,midx);

	while(!bfs.empty()){
		pair<int,P>X=bfs.top();
		P now=X.second;
		bfs.pop();
		int in=4;
		int dist=INF;
		int c,nx,ny;
		ny=now.first;nx=now.second;
		cnt+=culc(ny,nx);

		//cout<<ny<<" "<<nx<<" "<<culc(ny,nx)<<endl;
			ii++;
			if(ii>=k)break;

		for(int i=0;i<4;i++){//実際に次の一手を生成
			ny=now.first+dy[i];
			nx=now.second+dx[i];
			if(nx<0||ny<0||ny>=n||nx>=m||s[mp(ny,nx)])continue;

			s[mp(ny,nx)]=true;
			bfs.push(mp(culc(ny,nx),mp(ny,nx)));
			}

	}
	sum=(n-r+1)*(m-r+1);

	//cout<<cnt<<" "<<sum<<endl;
	double ans=(double)cnt/(double)sum;
	cout<<fixed<<ans<<endl;
	return 0;
}


#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int t[100][100];
const int INF=1000000000;
map<P,bool>s;
int n,m,r,k;//n*m,rはあみの範囲、k引き
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
inline int di(int y,int x){
		int sy=r,sx=r;

	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	return y+x;
}

inline int culc(int y,int x){
	int sy=r,sx=r;

	//sy=min(y+1,n-y);
	//sx=min(x+1,m-x);
	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	if(x+r>m)sx-=x+r-m;
//cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=min(r,sy)*min(r,sx);
	return solve;
	/*
	cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=r*sy+r*sx;*/

}
int main(){
	cin>>n>>m>>r>>k;
	int midy,midx;
	midy=n/2;
	midx=m/2;

	priority_queue<pair<int,P> >bfs;
	bfs.push(mp(culc(midy,midx),mp(midy,midx)));

	s[mp(midy,midx)]=true;
	__int64 cnt=0,sum=0;
	int ii=0;
	//int ma=culc(midy,midx);

	while(!bfs.empty()){
		pair<int,P>X=bfs.top();
		P now=X.second;
		bfs.pop();
		int in=4;
		int dist=INF;
		int c,nx,ny;
		ny=now.first;nx=now.second;
		cnt+=culc(ny,nx);

		//cout<<ny<<" "<<nx<<" "<<culc(ny,nx)<<endl;
			ii++;
			if(ii>=k)break;

		for(int i=0;i<4;i++){//実際に次の一手を生成
			ny=now.first+dy[i];
			nx=now.second+dx[i];
			if(nx<0||ny<0||ny>=n||nx>=m||s[mp(ny,nx)])continue;

			s[mp(ny,nx)]=true;
			bfs.push(mp(culc(ny,nx),mp(ny,nx)));
			}

	}
	sum=(n-r+1)*(m-r+1);

	//cout<<cnt<<" "<<sum<<endl;
	double ans=(double)cnt/(double)sum;
	printf("%.25lf",ans);
	return 0;
}


#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int t[100][100];
const int INF=1000000000;
map<P,bool>s;
__int64 n,m,r,k;//n*m,rはあみの範囲、k引き
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
inline int di(int y,int x){
		int sy=r,sx=r;

	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	return y+x;
}

inline int culc(int y,int x){
	__int64 sy=r,sx=r;

	//sy=min(y+1,n-y);
	//sx=min(x+1,m-x);
	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	if(x+r>m)sx-=x+r-m;
//cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=min(r,sy)*min(r,sx);
	return solve;
	/*
	cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=r*sy+r*sx;*/

}
int main(){
	cin>>n>>m>>r>>k;
	int midy,midx;
	midy=n/2;
	midx=m/2;

	priority_queue<pair<int,P> >bfs;
	bfs.push(mp(culc(midy,midx),mp(midy,midx)));

	s[mp(midy,midx)]=true;
	__int64 cnt=0,sum=0;
	int ii=0;
	//int ma=culc(midy,midx);

	while(!bfs.empty()){
		pair<int,P>X=bfs.top();
		P now=X.second;
		bfs.pop();
		int in=4;
		int dist=INF;
		int c,nx,ny;
		ny=now.first;nx=now.second;
		cnt+=culc(ny,nx);

	//	cout<<ny<<" "<<nx<<" "<<culc(ny,nx)<<endl;
			ii++;
			if(ii>=k)break;

		for(int i=0;i<4;i++){//実際に次の一手を生成
			ny=now.first+dy[i];
			nx=now.second+dx[i];
			if(nx<0||ny<0||ny>=n||nx>=m||s[mp(ny,nx)])continue;

			s[mp(ny,nx)]=true;
			bfs.push(mp(culc(ny,nx),mp(ny,nx)));
			}

	}
	sum=(n-r+1)*(m-r+1);

	cout<<cnt<<" "<<sum<<endl;
	double ans=(double)cnt/(double)sum;
	printf("%.25lf",ans);
	return 0;
}


#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int t[100][100];
const int INF=1000000000;
map<P,bool>s;
__int64 n,m,r,k;//n*m,rはあみの範囲、k引き
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
inline int di(int y,int x){
		int sy=r,sx=r;

	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	return y+x;
}

inline int culc(int y,int x){
	__int64 sy=r,sx=r;

	//sy=min(y+1,n-y);
	//sx=min(x+1,m-x);
	if(y+1-r<0)sy-=r-y-1;
	if(x+1-r<0)sx-=r-x-1;
	if(y+r>n)sy-=y+r-n;
	if(x+r>m)sx-=x+r-m;
//cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=min(r,sy)*min(r,sx);
	return solve;
	/*
	cout<<"Y"<<y<<" "<<x<<" "<<sy<<" "<<sx<<endl;
	int solve=r*sy+r*sx;*/

}
int main(){
	cin>>n>>m>>r>>k;
	int midy,midx;
	midy=n/2;
	midx=m/2;

	priority_queue<pair<int,P> >bfs;
	bfs.push(mp(culc(midy,midx),mp(midy,midx)));

	s[mp(midy,midx)]=true;
	__int64 cnt=0,sum=0;
	int ii=0;
	//int ma=culc(midy,midx);

	while(!bfs.empty()){
		pair<int,P>X=bfs.top();
		P now=X.second;
		bfs.pop();
		int in=4;
		int dist=INF;
		int c,nx,ny;
		ny=now.first;nx=now.second;
		cnt+=culc(ny,nx);

	//	cout<<ny<<" "<<nx<<" "<<culc(ny,nx)<<endl;
			ii++;
			if(ii>=k)break;

		for(int i=0;i<4;i++){//実際に次の一手を生成
			ny=now.first+dy[i];
			nx=now.second+dx[i];
			if(nx<0||ny<0||ny>=n||nx>=m||s[mp(ny,nx)])continue;

			s[mp(ny,nx)]=true;
			bfs.push(mp(culc(ny,nx),mp(ny,nx)));
			}

	}
	sum=(n-r+1)*(m-r+1);

	//cout<<cnt<<" "<<sum<<endl;
	double ans=(double)cnt/(double)sum;
	printf("%.25lf",ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<map>

using namespace std;
long long n,a[100][100],sol,m,r,k,p;
map<long long,long long>mapa[1000000+100];
priority_queue<pair<long long,pair<long long,long long>>>q;

string s;
void probaj(long long x,long long y)
{
    if(x>=1&&x<=n&&y>=1&&y<=m&&mapa[x][y]==0)
    {
        long long granica = max(1LL,1LL*x-r+1);
        long long granica1 = min(1LL*x,1LL*n-r+1);
        long long g = granica1-granica+1;

        long long ygranica = max(1LL,1LL*y-r+1);
        long long ygranica1 = min(1LL*y,1LL*m-r+1);
        long long yg = ygranica1-ygranica+1;

        q.push({1LL*g*yg,{x,y}});
        mapa[x][y]=1;
     //   cout<<min(x,n-r+1)*min(y,m-r+1)<<" "<<x<<" "<<y<<endl;
    }
}
int main()
{
    scanf("%lld %lld %lld %lld",&n,&m,&r,&k);
    long long x = n/2+(n%2);
    long long y = m/2+(m%2);

    probaj(x-1,y-1);
    probaj(x-1,y);
    probaj(x-1,y+1);
    probaj(x,y-1);
    probaj(x,y);
    probaj(x,y+1);
    probaj(x+1,y-1);
    probaj(x+1,y);
    probaj(x+1,y+1);
    probaj(r,r);

    long long l = n-r+1;
    long long desno = m-r+1;
    long long u = l*desno;

    long long pp = min(x,n-r+1);
    long long pp1 = min(y,m-r+1);
  //  cout<<pp*pp1<<" "<<x<<" "<<y<<endl;
    while(k--)
    {
        pair<long long,pair<long long,long long>> p = q.top();
        mapa[p.second.first][p.second.second]=1;
        sol+=p.first;
      //  cout<<p.first<<" "<<p.second.first<<" "<<p.second.second<<endl;

        long long x = p.second.first;
        long long y = p.second.second;
        long long x1 = p.second.first-1;
        long long x2 = p.second.first+1;
        long long y1 = p.second.second+1;
        long long y2 = p.second.second-1;
        probaj(x1,y1);
        probaj(x1,y);
        probaj(x1,y2);
        probaj(x2,y1);
        probaj(x2,y);
        probaj(x2,y2);
        probaj(x,y1);
        probaj(x,y2);
        probaj(x,y);
        q.pop();
    }
    double sol1 = sol*1.0/u;
    printf("%.10lf\n",sol1);

    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<map>

using namespace std;
long long n,a[100][100],sol,m,r,k,p;
map<long long,long long>mapa[1000000+100];
priority_queue<pair<long long,pair<long long,long long>>>q;

string s;
void probaj(long long x,long long y)
{
    if(x>=1&&x<=n&&y>=1&&y<=m&&mapa[x][y]==0)
    {
        long long granica = max(1LL,1LL*x-r+1);
        long long granica1 = min(1LL*x,1LL*n-r+1);
        long long g = granica1-granica+1;

        long long ygranica = max(1LL,1LL*y-r+1);
        long long ygranica1 = min(1LL*y,1LL*m-r+1);
        long long yg = ygranica1-ygranica+1;

        q.push({1LL*g*yg,{x,y}});
        mapa[x][y]=1;
    }
}
int main()
{
    scanf("%lld %lld %lld %lld",&n,&m,&r,&k);
    long long x = n/2+(n%2);
    long long y = m/2+(m%2);

    probaj(x,y);

    long long l = n-r+1;
    long long desno = m-r+1;
    long long u = l*desno;

    long long pp = min(x,n-r+1);
    long long pp1 = min(y,m-r+1);
  //  cout<<pp*pp1<<" "<<x<<" "<<y<<endl;
    while(k--)
    {
        pair<long long,pair<long long,long long>> p = q.top();
        q.pop();
        sol+=p.first;

        long long x = p.second.first;
        long long y = p.second.second;

        probaj(x-1,y-1);
        probaj(x-1,y);
        probaj(x-1,y+1);
        probaj(x,y-1);
        probaj(x,y);
        probaj(x,y+1);
        probaj(x+1,y-1);
        probaj(x+1,y);
        probaj(x+1,y+1);
    }
    double sol1 = sol*1.0/u;
    printf("%.10lf\n",sol1);

    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<map>

using namespace std;
int n,a[100][100],sol,m,r,k,p;
map<int,int>mapa[1000000+100];
priority_queue<pair<long long,pair<int,int>>>q;

string s;
void probaj(int x,int y)
{
    if(x>=1&&x<=n&&y>=1&&y<=m&&mapa[x][y]==0)
    {
        q.push({1LL*min(x,n-r+1)*min(y,m-r+1),{x,y}});
        mapa[x][y]=1;
        cout<<x*y<<" "<<x<<" "<<y<<endl;
    }
}
int main()
{
    scanf("%d %d %d %d",&n,&m,&r,&k);
    int x = n/2+(n%2);
    int y = m/2+(m%2);
    q.push({min(x,n-r+1)*min(y,m-r+1),{x,y}});
    mapa[x][y] =1;
    long long l = n-r+1;
    long long r = m-r+1;
    long long u = l*r;
    //cout<<x*y<<" "<<x<<" "<<y<<endl;
    while(k)
    {
        pair<long long,pair<int,int>> p = q.top();
        mapa[p.second.first][p.second.second]=1;
        sol+=p.first;

        int x = p.second.first;
        int y = p.second.second;
        int x1 = p.second.first-1;
        int x2 = p.second.first+1;
        int y1 = p.second.second+1;
        int y2 = p.second.second-1;
        probaj(x1,y1);
        probaj(x1,y);
        probaj(x1,y2);
        probaj(x2,y1);
        probaj(x2,y);
        probaj(x2,y2);
        probaj(x,y1);
        probaj(x,y2);
        probaj(x,y);
        q.pop();
        k--;
    }
    double sol1 = sol*1.0/u;
    printf("%.10lf\n",sol1);

    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<map>

using namespace std;
int n,a[100][100],sol,m,r,k,p;
map<int,int>mapa[1000000+100];
priority_queue<pair<long long,pair<int,int>>>q;

string s;
void probaj(int x,int y)
{
    if(x>=1&&x<=n&&y>=1&&y<=m&&mapa[x][y]==0)
    {
        q.push({1LL*min(x,n-r+1)*min(y,m-r+1),{x,y}});
        mapa[x][y]=1;
      //  cout<<x*y<<" "<<x<<" "<<y<<endl;
    }
}
int main()
{
    scanf("%d %d %d %d",&n,&m,&r,&k);
    int x = n/2+(n%2);
    int y = m/2+(m%2);
    q.push({min(x,n-r+1)*min(y,m-r+1),{x,y}});
    mapa[x][y] =1;
    long long l = n-r+1;
    long long r = m-r+1;
    long long u = l*r;
    //cout<<x*y<<" "<<x<<" "<<y<<endl;
    while(k)
    {
        pair<long long,pair<int,int>> p = q.top();
        mapa[p.second.first][p.second.second]=1;
        sol+=p.first;

        int x = p.second.first;
        int y = p.second.second;
        int x1 = p.second.first-1;
        int x2 = p.second.first+1;
        int y1 = p.second.second+1;
        int y2 = p.second.second-1;
        probaj(x1,y1);
        probaj(x1,y);
        probaj(x1,y2);
        probaj(x2,y1);
        probaj(x2,y);
        probaj(x2,y2);
        probaj(x,y1);
        probaj(x,y2);
        probaj(x,y);
        q.pop();
        k--;
    }
    double sol1 = sol*1.0/u;
    printf("%.10lf\n",sol1);

    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<map>

using namespace std;
long long n,a[100][100],sol,m,r,k,p;
map<long long,long long>mapa[1000000+100];
priority_queue<pair<long long,pair<long long,long long>>>q;

string s;
void probaj(long long x,long long y)
{
    if(x>=1&&x<=n&&y>=1&&y<=m&&mapa[x][y]==0)
    {
        long long granica = max(1LL,1LL*x-r+1);
        long long granica1 = min(1LL*x,1LL*n-r+1);
        long long g = granica1-granica+1;

        long long ygranica = max(1LL,1LL*y-r+1);
        long long ygranica1 = min(1LL*y,1LL*m-r+1);
        long long yg = ygranica1-ygranica+1;

        q.push({1LL*g*yg,{x,y}});
        mapa[x][y]=1;
    }
}
int main()
{
    scanf("%lld %lld %lld %lld",&n,&m,&r,&k);
    long long x = n/2+(n%2);
    long long y = m/2+(m%2);

    probaj(x-1,y-1);
    probaj(x-1,y);
    probaj(x-1,y+1);
    probaj(x,y-1);
    probaj(x,y);
    probaj(x,y+1);
    probaj(x+1,y-1);
    probaj(x+1,y);
    probaj(x+1,y+1);

    probaj(r-1,r-1);
    probaj(r-1,r);
    probaj(r-1,r+1);
    probaj(r,r-1);
    probaj(r,r);
    probaj(r,r+1);
    probaj(r+1,r-1);
    probaj(r+1,r);
    probaj(r+1,r+1);

    long long l = n-r+1;
    long long desno = m-r+1;
    long long u = l*desno;

    long long pp = min(x,n-r+1);
    long long pp1 = min(y,m-r+1);
  //  cout<<pp*pp1<<" "<<x<<" "<<y<<endl;
    while(k--)
    {
        pair<long long,pair<long long,long long>> p = q.top();
        q.pop();
        sol+=p.first;

        long long x = p.second.first;
        long long y = p.second.second;

        probaj(x-1,y-1);
        probaj(x-1,y);
        probaj(x-1,y+1);
        probaj(x,y-1);
        probaj(x,y);
        probaj(x,y+1);
        probaj(x+1,y-1);
        probaj(x+1,y);
        probaj(x+1,y+1);
    }
    double sol1 = sol*1.0/u;
    printf("%.10lf\n",sol1);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; i++)
#define de(x) cout<<#x<<" = "<<x<<endl
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
vector<int>vis[N];
ll sum;
int n,m,r,k;
set<int> used[N];
int dx[4] = { -1, 0, 0, 1 };
int dy[4] = { 0, -1, 1, 0 };
ll qpow(ll a,ll b)
{
    ll ret=1;
    for(;b;a=a*a,b>>=1) if(b&1) ret=a*ret;
    return ret;
}
ll get_ans(int x,int y)
{
    return (min(n + 1, x + r) - max(x, r)) * 1LL * (min(m + 1, y + r) - max(y, r));
}
bool vsd(int x,int y)
{
    vector<int>::iterator it=find(vis[x].begin(),vis[x].end(),y);
    if(it==vis[x].end()) return false;
    else return true;
}
bool ok(int x, int y) {
	return min(x, y) > 0 && x <= n && y <= m;
}
struct cmp {
	bool operator()(const pii &a, const pii &b) {
		ll f_a = get_ans(a.first, a.second);
		ll f_b = get_ans(b.first, b.second);
		return f_a > f_b || (f_a == f_b && a > b);
	}
};

set<pii, cmp> s;
/*double bfs() {
	s.insert(mp((n + 1) / 2, (m + 1) / 2));
	used[(n + 1) / 2].insert((m + 1) / 2);

	ll total = 0;
	forn(i, k) {
		pii e = *s.begin();
		s.erase(s.begin());

		int x = e.first, y = e.second;
		total += get_ans(x, y);

		forn(j, 4) {
			int _x = x + dx[j], _y = y + dy[j];
			if (!ok(_x, _y) || used[_x].count(_y)) continue;

			s.insert(mp(_x, _y));
			used[_x].insert(_y);
		}
	}

	return (double)total / ((n - r + 1) * 1LL * (m - r + 1));
}*/
double bfs()
{
    ll sum=0;
    s.insert(mp((n + 1) / 2, (m + 1) / 2));
    vis[(n+1)/2].pb((m+1)/2);
    for(int j=1;j<=k;j++)
    {
        pii e=*s.begin();
        s.erase(s.begin());
        int x=e.first,y=e.second;
        sum+=get_ans(x,y);
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i],ny=y+dy[i];
           // if (!ok(nx, ny) || used[nx].count(ny)) continue;
            if(nx<1||ny<1||nx>n||ny>n||vsd(nx,ny)) continue;
            s.insert(pii(nx,ny));
            vis[nx].pb(ny);
        }
    }

	return (double)sum / ((n - r + 1) * 1LL * (m - r + 1));
}
int main()
{
    scanf("%d%d%d%d",&n,&m,&r,&k);
    if(n>m)swap(n,m);
    if(n==1&&m==1) printf("%.10lf\n",1.0);
    else{
        printf("%.11lf",bfs());
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; i++)
#define de(x) cout<<#x<<" = "<<x<<endl
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
vector<int>vis[N];
ll sum;
int n,m,r,k;
set<int> used[N];
int dx[4] = { -1, 0, 0, 1 };
int dy[4] = { 0, -1, 1, 0 };
ll qpow(ll a,ll b)
{
    ll ret=1;
    for(;b;a=a*a,b>>=1) if(b&1) ret=a*ret;
    return ret;
}
ll get_ans(int x,int y)
{
    return (min(n + 1, x + r) - max(x, r)) * 1LL * (min(m + 1, y + r) - max(y, r));
}
bool vsd(int x,int y)
{
    vector<int>::iterator it=find(vis[x].begin(),vis[x].end(),y);
    if(it==vis[x].end()) return false;
    else return true;
}
bool ok(int x, int y) {
	return min(x, y) > 0 && x <= n && y <= m;
}
struct cmp {
	bool operator()(const pii &a, const pii &b) {
		ll f_a = get_ans(a.first, a.second);
		ll f_b = get_ans(b.first, b.second);
		return f_a > f_b || (f_a == f_b && a > b);
	}
};

set<pii, cmp> s;
/*double bfs() {
	s.insert(mp((n + 1) / 2, (m + 1) / 2));
	used[(n + 1) / 2].insert((m + 1) / 2);

	ll total = 0;
	forn(i, k) {
		pii e = *s.begin();
		s.erase(s.begin());

		int x = e.first, y = e.second;
		total += get_ans(x, y);

		forn(j, 4) {
			int _x = x + dx[j], _y = y + dy[j];
			if (!ok(_x, _y) || used[_x].count(_y)) continue;

			s.insert(mp(_x, _y));
			used[_x].insert(_y);
		}
	}

	return (double)total / ((n - r + 1) * 1LL * (m - r + 1));
}*/
double bfs()
{
    ll sum=0;
    s.insert(mp((n + 1) / 2, (m + 1) / 2));
    used[(n + 1) / 2].insert((m + 1) / 2);
    //vis[(n+1)/2].pb((m+1)/2);
    for(int j=1;j<=k;j++)
    {
        pii e=*s.begin();
        s.erase(s.begin());
        int x=e.first,y=e.second;
        sum+=get_ans(x,y);
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i],ny=y+dy[i];
            if (!ok(nx, ny) || used[nx].count(ny)) continue;
           // if(nx<1||ny<1||nx>n||ny>n||used[nx].count(ny)) continue;
            s.insert(pii(nx,ny));
            used[nx].insert(ny);
        }
    }

	return (double)sum / ((n - r + 1) * 1LL * (m - r + 1));
}
int main()
{
    scanf("%d%d%d%d",&n,&m,&r,&k);
    if(n>m)swap(n,m);
    if(n==1&&m==1) printf("%.10lf\n",1.0);
    else{
        printf("%.11lf",bfs());
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; i++)
#define de(x) cout<<#x<<" = "<<x<<endl
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
vector<int>vis[N];
ll sum;
int n,m,r,k;
set<int> used[N];
int dx[4] = { -1, 0, 0, 1 };
int dy[4] = { 0, -1, 1, 0 };
ll qpow(ll a,ll b)
{
    ll ret=1;
    for(;b;a=a*a,b>>=1) if(b&1) ret=a*ret;
    return ret;
}
ll get_ans(int x,int y)
{
    return (min(n + 1, x + r) - max(x, r)) * 1LL * (min(m + 1, y + r) - max(y, r));
}
bool vsd(int x,int y)
{
    vector<int>::iterator it=find(vis[x].begin(),vis[x].end(),y);
    if(it==vis[x].end()) return false;
    else return true;
}
bool ok(int x, int y) {
	return min(x, y) > 0 && x <= n && y <= m;
}
struct cmp {
	bool operator()(const pii &a, const pii &b) {
		ll f_a = get_ans(a.first, a.second);
		ll f_b = get_ans(b.first, b.second);
		return f_a > f_b || (f_a == f_b && a > b);
	}
};

set<pii, cmp> s;
double bfs() {
	s.insert(mp((n + 1) / 2, (m + 1) / 2));
	used[(n + 1) / 2].insert((m + 1) / 2);

	ll total = 0;
	forn(i, k) {
		pii e = *s.begin();
		s.erase(s.begin());

		int x = e.first, y = e.second;
		total += get_ans(x, y);

		forn(j, 4) {
			int _x = x + dx[j], _y = y + dy[j];
			if (!ok(_x, _y) || used[_x].count(_y)) continue;

			s.insert(mp(_x, _y));
			used[_x].insert(_y);
		}
	}

	return (double)total / ((n - r + 1) * 1LL * (m - r + 1));
}
/*double bfs()
{
    ll sum=0;
    s.insert(mp((n + 1) / 2, (m + 1) / 2));
    vis[(n+1)/2].pb((m+1)/2);
    for(int j=1;j<=k;j++)
    {
        pii e=*s.begin();
        s.erase(s.begin());
        int x=e.first,y=e.second;
        sum+=get_ans(x,y);
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i],ny=y+dy[i];
           // if (!ok(nx, ny) || used[nx].count(ny)) continue;
            if(nx<1||ny<1||nx>n||ny>n||vsd(nx,ny)) continue;
            s.insert(pii(nx,ny));
            vis[nx].pb(ny);
        }
    }

	return (double)sum / ((n - r + 1) * 1LL * (m - r + 1));
}*/
int main()
{
    scanf("%d%d%d%d",&n,&m,&r,&k);
    if(n>m)swap(n,m);
    if(n==1&&m==1) printf("%.10lf\n",1.0);
    else{
        printf("%.11lf",bfs());
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; i++)
#define de(x) cout<<#x<<" = "<<x<<endl
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
vector<int>vis[N];
ll sum;
int n,m,r,k;
set<int> used[N];
int dx[4] = { -1, 0, 0, 1 };
int dy[4] = { 0, -1, 1, 0 };
ll qpow(ll a,ll b)
{
    ll ret=1;
    for(;b;a=a*a,b>>=1) if(b&1) ret=a*ret;
    return ret;
}
ll get_ans(int x,int y)
{
    return (min(n + 1, x + r) - max(x, r)) * 1LL * (min(m + 1, y + r) - max(y, r));
}
bool vsd(int x,int y)
{
    vector<int>::iterator it=find(vis[x].begin(),vis[x].end(),y);
    if(it==vis[x].end()) return false;
    else return true;
}
bool ok(int x, int y) {
	return min(x, y) > 0 && x <= n && y <= m;
}
struct cmp {
	bool operator()(const pii &a, const pii &b) {
		ll f_a = get_ans(a.first, a.second);
		ll f_b = get_ans(b.first, b.second);
		return f_a > f_b || (f_a == f_b && a > b);
	}
};

set<pii, cmp> s;
/*double bfs() {
	s.insert(mp((n + 1) / 2, (m + 1) / 2));
	used[(n + 1) / 2].insert((m + 1) / 2);

	ll total = 0;
	forn(i, k) {
		pii e = *s.begin();
		s.erase(s.begin());

		int x = e.first, y = e.second;
		total += get_ans(x, y);

		forn(j, 4) {
			int _x = x + dx[j], _y = y + dy[j];
			if (!ok(_x, _y) || used[_x].count(_y)) continue;

			s.insert(mp(_x, _y));
			used[_x].insert(_y);
		}
	}

	return (double)total / ((n - r + 1) * 1LL * (m - r + 1));
}*/
double bfs()
{
    ll sum=0;
    s.insert(mp((n + 1) / 2, (m + 1) / 2));
    used[(n + 1) / 2].insert((m + 1) / 2);
    //vis[(n+1)/2].pb((m+1)/2);
    for(int j=1;j<=k;j++)
    {
        pii e=*s.begin();
        s.erase(s.begin());
        int x=e.first,y=e.second;
        sum+=get_ans(x,y);
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i],ny=y+dy[i];
           // if (!ok(nx, ny) || used[nx].count(ny)) continue;
            if(nx<1||ny<1||nx>n||ny>n||used[nx].count(ny)) continue;
            s.insert(pii(nx,ny));
            used[nx].insert(ny);
        }
    }

	return (double)sum / ((n - r + 1) * 1LL * (m - r + 1));
}
int main()
{
    scanf("%d%d%d%d",&n,&m,&r,&k);
    if(n>m)swap(n,m);
    if(n==1&&m==1) printf("%.10lf\n",1.0);
    else{
        printf("%.11lf",bfs());
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef long double ld;
typedef long long ll;
const int N=100005;
const ld EPS=1e-10;
struct Item{
    ll p;
    int b;
    bool operator < (const Item& rhs) const {
        return p<rhs.p;
    }
};
bool cmp(ll a,ll b)
{
    return a>b;
}
inline ll mi(ll a,ll b)
{
    if(a<b) return a;
    return b;
}
inline ll ma(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
priority_queue<Item> que;
ll n,m,r,k,col[N]={},row[N]={},ans=0;
int main(void)
{
    scanf("%lld%lld%lld%lld",&n,&m,&r,&k);
    for(ll i=0;i<m;i++) {
        row[i]=(mi(ll(i+r-1),m-1)-r+1-ma(ll(i-r+1),0LL)+1);
    }
    for(ll i=0;i<n;i++) {
        col[i]=(mi(ll(i+r-1),n-1)-r+1-ma(ll(i-r+1),0LL)+1);
    }
    sort(row,row+m,cmp);
    sort(col,col+n,cmp);
    for(int i=0;i<m;i++) {
        que.push((Item){row[i]*col[0],0});
    }
    for(int i=0;i<k;i++) {
        Item item=que.top(); que.pop();
        ans+=item.p;
        if(item.b<n) {
            que.push((Item){item.p/col[item.b]*col[item.b+1],item.b+1});
        }
    }
    double res=double(ans)/double((m-r+1)*(n-r+1));
    printf("%.9f",res);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Node{
	long long int x,y,cnt;
	Node(long long int i=0,long long int j=0,long long int k=0){
		x=i;y=j;cnt=k;
	}
	friend bool operator <(const Node &a,const Node &b){
		return a.cnt<b.cnt;
	}
};

long long int n,m,r,k;
long long ans;
int d[10]={0,1,0,-1,0};
string s;
priority_queue <Node> q;
map<pair<int,int>,bool> v;
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
void bfs(long long int sx,long long int sy){
	v[make_pair(sx,sy)]=true;
	q.push(Node(sx,sy,cal(sx,sy)));
	for(int j=1;j<=k;j++)
	{
		Node cur=q.top();q.pop();
		ans+=cur.cnt;
		for(int i=0;i<4;i++){
			long long int nx=cur.x+d[i];
			long long int ny=cur.y+d[i+1];
			if(nx<1||nx>n||ny<1||ny>m||v[make_pair(nx,ny)]) continue;
			v[make_pair(nx,ny)]=true;
			q.push(Node(nx,ny,cal(nx,ny)));
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&k);
	double tot=(n-r+1)*(m-r+1);
	bfs((n+1)/2,(m+1)/2);
	cout<<fixed<<setprecision(10)<<ans/tot<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<set>
using namespace std;

int n,m,r,k;
long long ans;

const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};

int f(int x,int y){
	return (min(x+r-1,n)-max(r,x)+1)*(min(y+r-1,m)-max(r,y)+1);
}

struct node{
	int x,y;
	node(int x=0,int y=0):x(x),y(y){}
	bool operator < (const node& n)const{
		return f(x,y)<f(n.x,n.y);
	}
};

priority_queue<node> q;
set<int> s[100005];

void bfs(int x,int y){
	q.push(node(x,y));
	s[x].insert(y);
	int x1,y1,x2,y2;
	while(!q.empty()&&k>0){
		x1=q.top().x; y1=q.top().y;
		ans+=f(x1,y1);
		k--;
		q.pop();
		for(int i=0;i<4;i++){
			x2=x1+dx[i];
			y2=y1+dy[i];
			if(x2<=0||x2>n||y2<=0||y2>n) continue;
			if(s[x2].count(y2)==0){
				q.push(node(x2,y2));
				s[x2].insert(y2);
			}
		}
	}
}

int main(){
	cin>>n>>m>>r>>k;
	bfs((n+1)/2,(m+1)/2);
	printf("%.9f",double(ans)/double(n-r+1)/double(m-r+1));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Node{
	long long int x,y,cnt;
	Node(long long int i=0,long long int j=0,long long int k=0){
		x=i;y=j;cnt=k;
	}
	friend bool operator <(const Node &a,const Node &b){
		return a.cnt<b.cnt;
	}
};
long long int n,m,r,k;
long long int ans;
long long int tot;
int d[10]={0,1,0,-1,0};
string s;
priority_queue <Node> q;
map <string,bool> v;
void bfs(long long int sx,long long int sy){
	s.clear();
	s+=sx;s+=sy;v[s]=true;
	q.push(Node(sx,sy,(min(n,sx+r-1)-max(sx,r)+1)*(min(m,sy+r-1)-max(sy,r)+1)));
	while(!q.empty()){
		Node cur=q.top();
		ans+=cur.cnt;k--;
		if(k==0) return;
		for(int i=0;i<4;i++){
			long long int nx=cur.x+d[i];
			long long int ny=cur.y+d[i+1];
			if(nx<1||nx>n||ny<1||ny>m) continue;
			s.clear();
			s+=nx;s+=ny;
			if(!v[s]){
				v[s]=true;
				q.push(Node(nx,ny,(min(n,nx+r-1)-max(nx,r)+1)*(min(m,ny+r-1)-max(ny,r)+1)));
			}
		}
		q.pop();
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&k);
	tot=(n-r+1)*(m-r+1);
	bfs((n+1)/2,(m+1)/2);
	printf("%.10f",1.0*ans/tot);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Node{
	long long int x,y,cnt;
	Node(long long int i=0,long long int j=0,long long int k=0){
		x=i;y=j;cnt=k;
	}
	friend bool operator <(const Node &a,const Node &b){
		return a.cnt<b.cnt;
	}
};
long long int n,m,r,k;
double ans;
int d[10]={0,1,0,-1,0};
string s;
priority_queue <Node> q;
map <string,bool> v;
long long cal(long long x,long long y){
    return (min(n,x+r-1)-max(x,r)+1)*(min(m,y+r-1)-max(y,r)+1);
}
void bfs(long long int sx,long long int sy){
	s.clear();
	s+=sx;s+=sy;v[s]=true;
	q.push(Node(sx,sy,cal(sx,sy)));
	for(int j=1;j<=k;j++)
	{
		Node cur=q.top();q.pop();
		ans+=cur.cnt;
		for(int i=0;i<4;i++){
			long long int nx=cur.x+d[i];
			long long int ny=cur.y+d[i+1];
			s.clear();s+=nx;s+=ny;
			if(nx<1||nx>n||ny<1||ny>m||v[s]) continue;
			v[s]=true;
			q.push(Node(nx,ny,cal(nx,ny)));
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&k);
	double tot=(n-r+1)*(m-r+1);
	bfs((n+1)/2,(m+1)/2);
	printf("%.10f",ans/tot);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int mx[] ={0,-1,0,1};
int my[] = {-1,0,1,0};

struct Node
{
    int i,j;
    long long we;

};
bool operator <(Node x,Node y)
{
    return x.we < y.we;
}

vector<long long> sss;
int main()
{
    map<pair<int,int>,int >rec;
    rec.clear();
    long long n,m,r,k;
    cin >> n >> m >> r >> k;
    int loop = k;
    k = r * k;
    long long ans=min((n-r+1)*(m-r+1),r*r);
    sss.push_back(ans);
    priority_queue<Node>q;
    Node s;
    s.i = n-r+1;
    s.j = m-r+1;
    rec[make_pair(s.i,s.j)] = 1;
    s.we = ans;
    q.push(s);;
    k--;
    ans = 0;
    while(k > 0 && !q.empty())
    {
        Node now = q.top();
        q.pop();
        for(int i = 0; i < 4; i++)
        {
            long long ni = now.i + mx[i];
            long long nj = now.j + my[i];
            if(ni < 1 || nj < 1 ||rec[make_pair(ni,nj)] == 1 || ni > n || nj > m)
                continue;
            Node p;
            p.i = ni;
            p.j = nj;
            rec[make_pair(p.i,p.j)] = 1;
            long long sa =  0;
            long long sb =  0;
            long long ppi = p.i <= r ? 1 : p.i - r + 1;
            long long ppj = p.j <= r ? 1 : p.j - r + 1;
            sa = (p.i > n - r + 1 ? n - r + 1 : p.i) - ppi + 1;
            sb = (p.j > m - r + 1 ? m - r + 1 : p.j) - ppj + 1;
            p.we = sa * sb;
            sss.push_back(p.we);
            k--;
            if(k == 0)
                break;
            q.push(p);
        }
    }
    sort(sss.begin(),sss.end());
    reverse(sss.begin(),sss.end());
    for(int i = 0; i < loop; i++)
        ans+=sss[i];
    double ss = (n-r + 1) * (m -r +1)*1.0;
    printf("%.12lf\n",ans*1.0/ss);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int mx[] ={0,-1,0,1};
int my[] = {-1,0,1,0};

struct Node
{
    int i,j;
    long long we;

};
bool operator <(Node x,Node y)
{
    return x.we < y.we;
}

vector<long long> sss;
int main()
{
    map<pair<int,int>,int >rec;
    rec.clear();
    long long n,m,r,k;
    cin >> n >> m >> r >> k;
    int loop = k;
    k = min((n-r+1),(m-r+1)) * k;
    long long ans=min((n-r+1)*(m-r+1),r*r);
    sss.push_back(ans);
    priority_queue<Node>q;
    Node s;
    s.i = n-r+1;
    s.j = m-r+1;
    rec[make_pair(s.i,s.j)] = 1;
    s.we = ans;
    q.push(s);;
    k--;
    ans = 0;
    while(k > 0 && !q.empty())
    {
        Node now = q.top();
        q.pop();
        for(int i = 0; i < 4; i++)
        {
            long long ni = now.i + mx[i];
            long long nj = now.j + my[i];
            if(ni < 1 || nj < 1 ||rec[make_pair(ni,nj)] == 1 || ni > n || nj > m)
                continue;
            Node p;
            p.i = ni;
            p.j = nj;
            rec[make_pair(p.i,p.j)] = 1;
            long long sa =  0;
            long long sb =  0;
            long long ppi = p.i <= r ? 1 : p.i - r + 1;
            long long ppj = p.j <= r ? 1 : p.j - r + 1;
            sa = (p.i > n - r + 1 ? n - r + 1 : p.i) - ppi + 1;
            sb = (p.j > m - r + 1 ? m - r + 1 : p.j) - ppj + 1;
            p.we = sa * sb;
            sss.push_back(p.we);
            k--;
            if(k == 0)
                break;
            q.push(p);
        }
    }
    sort(sss.begin(),sss.end());
    reverse(sss.begin(),sss.end());
    for(int i = 0; i < loop; i++)
        ans+=sss[i];
    double ss = (n-r + 1) * (m -r +1)*1.0;
    printf("%.12lf\n",ans*1.0/ss);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int mx[] ={0,-1,0,1};
int my[] = {-1,0,1,0};

struct Node
{
    int i,j;
    long long we;

};
bool operator <(Node x,Node y)
    {
        return x.we < y.we;
    }

int main()
{
    map<pair<int,int>,int >rec;
    rec.clear();
    long long n,m,r,k;
    cin >> n >> m >> r >> k;
    long long ans = min((n-r+1)*(m-r+1),r*r);
    priority_queue<Node>q;
    Node s;
    s.i = n-r+1;
    s.j = m-r+1;
    rec[make_pair(s.i,s.j)] = 1;
    s.we = ans;
    q.push(s);;
    k--;
    while(k > 0)
    {
        Node now = q.top();
        q.pop();
        for(int i = 0; i < 4; i++)
        {
            long long ni = now.i + mx[i];
            long long nj = now.j + my[i];
            if(ni < 1 || nj < 1 ||rec[make_pair(ni,nj)] == 1 || ni > n || nj > m)
                continue;
            Node p;
            p.i = ni;
            p.j = nj;
            rec[make_pair(p.i,p.j)] = 1;
            p.we = min((n-r+1-max(p.i-r+1,1LL)+1)*(m-r+1-max(p.j-r+1,1LL)+1),r*r);
            ans += p.we;
            k--;
            if(k == 0)
                break;
            q.push(p);
        }
    }

    double ss = (n-r + 1) * (m -r +1)*1.0;
    printf("%.12lf\n",ans*1.0/ss);
    return 0;
}