#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,x,y,n,dif;
        cin>>a>>b>>x>>y>>n;
        if(x<=a)
        {

        }
        else
        {
            dif=x-a;
        }
        if(y<=b)
        {

        }
        else
        {
            dif+=y-b;
        }
        if(n>=dif)
        {
            cout<<x*y<<"\n";
            continue;
        }
        if(a<b)
        {
        swap(a,b);
        swap(x,y);
        }
        else
        {
            if(n>(y-b))
            {
                n=n-(y-b);
                b=b-(y-b);
                a=a-n;

            }
            else
            {
                b=b-n;
            }

        }
        cout<<a*b<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,x,y,n,dif;
        cin>>a>>b>>x>>y>>n;
        if(x<=a && y<=b)
        {
            cout<<a*b<<"\n";
            continue;
        }
        if(x<=a)
        {

        }
        else
        {
            dif=x-a;
        }
        if(y<=b)
        {

        }
        else
        {
            dif+=y-b;
        }
        if(n>=dif)
        {
            cout<<x*y<<"\n";
            continue;
        }
        if(a<b)
        {
        swap(a,b);
        swap(x,y);
        }
        else
        {
            if(n>(y-b))
            {
                n=n-(y-b);
                b=b-(y-b);
                a=a-n;

            }
            else
            {
                b=b-n;
            }

        }
        cout<<a*b<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,x,y,n,dif=0;
        cin>>a>>b>>x>>y>>n;
        if(a<=x && b<=y)
        {
            cout<<a*b<<"\n";
            continue;
        }
        if(a<=x)
        {

        }
        else
        {
            dif=x-a;
        }
        if(b<=y)
        {

        }
        else
        {
            dif+=y-b;
        }
        if(n>=dif)
        {
            cout<<x*y<<"\n";
            continue;
        }
        if(a<b)
        {
        swap(a,b);
        swap(x,y);
        }
        else
        {
            if(n>(y-b))
            {
                n=n-(y-b);
                b=b-(y-b);
                a=a-n;

            }
            else
            {
                b=b-n;
            }

        }
        cout<<a*b<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,x,y,n,dif=0;
        cin>>a>>b>>x>>y>>n;
            dif=a-x;
            dif+=b-y;
        if(n>=dif)
        {
            cout<<x*y<<"\n";
            continue;

        }
        if(a<b)
        {
        swap(a,b);
        swap(x,y);
        }

        long long int m=n,z=x,q=y,f=a,g=b;
            if(n>(b-y))
            {
                n=n-(b-y);
                b=b-(b-y);
                a=a-n;

            }
            else
            {
                b=b-n;
            }
            if(m>(f-z))
            {
                m=m-(f-z);
                f=f-(f-z);
                g=g-m;
            }
            else
            {
                f=f-m;
            }

        cout<<min(a*b,f*g)<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long int a,b,x,y,n,dif=0;
        cin>>a>>b>>x>>y>>n;
            dif=x-a;
            dif+=y-b;
        if(n>=dif)
        {
            cout<<x*y<<"\n";
            continue;

        }
        if(a<b)
        {
        swap(a,b);
        swap(x,y);
        }
        else
        {
            if(n>(y-b))
            {
                n=n-(y-b);
                b=b-(y-b);
                a=a-n;

            }
            else
            {
                b=b-n;
            }

        }
        cout<<a*b<<"\n";
    }
}


#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int t;
	long long a, b, x, y, n, f1, f2, altf1, altf2;
	cin >> t;
	vector<long long> listp(t);
	for (int k = 0; k < t; k++) {
		f1 = 0; f2 = 0;
		cin >> a >> b >> x >> y >> n;
		if (a - n > x) {
			f1 = a - n; f2 = b;
		}
		else {
			f1 = x;
			if (b - (n - (a - x)) > y) {
				f2 = b - (n - (a - x));
			}
			else {
				f2 = y;
			}
		}
		if (b - n > y) {
			altf1 = b - n; altf2 = a;
		}
		else {
			altf1 = y;
			if (a - (n - (b - y)) > x) {
				altf2 = a - (n - (b - y));
			}
			else {
				altf2 = x;
			}
		}
		listp[k] = min(1ll * f1 * f2, 1ll * altf1 * altf2);
	}
	for (int k = 0; k < t; k++) {
		cout << listp[k] << "\n";
	}
}


#include <iostream>
#include <cmath>
#include <minmax.h>
#include <vector>
using namespace std;

int main() {
	int t;
	long long a, b, x, y, n, f1, f2, altf1, altf2;
	cin >> t;
	vector<long long> listp(t);
	for (int k = 0; k < t; k++) {
		f1 = 0; f2 = 0;
		cin >> a >> b >> x >> y >> n;
		if (a - n > x) {
			f1 = a - n; f2 = b;
		}
		else {
			f1 = x;
			if (b - (n - (a - x)) > y) {
				f2 = b - (n - (a - x));
			}
			else {
				f2 = y;
			}
		}
		if (b - n > y) {
			altf1 = b - n; altf2 = a;
		}
		else {
			altf1 = y;
			if (a - (n - (b - y)) > x) {
				altf2 = a - (n - (b - y));
			}
			else {
				altf2 = x;
			}
		}
		listp[k] = min(1ll * f1 * f2, 1ll * altf1 * altf2);
	}
	for (int k = 0; k < t; k++) {
		cout << listp[k] << "\n";
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
	int t;
	long long a, b, x, y, n, f1, f2, altf1, altf2;
	cin >> t;
	vector<long long> listp(t);
	for (int k = 0; k < t; k++) {
		f1 = 0; f2 = 0;
		cin >> a >> b >> x >> y >> n;
		if (a - n > x) {
			f1 = a - n; f2 = b;
		}
		else {
			f1 = x;
			if (b - (n - (a - x)) > y) {
				f2 = b - (n - (a - x));
			}
			else {
				f2 = y;
			}
		}
		if (b - n > y) {
			altf1 = b - n; altf2 = a;
		}
		else {
			altf1 = y;
			if (a - (n - (b - y)) > x) {
				altf2 = a - (n - (b - y));
			}
			else {
				altf2 = x;
			}
		}
		listp[k] = min(1ll * f1 * f2, 1ll * altf1 * altf2);
	}
	for (int k = 0; k < t; k++) {
		cout << listp[k] << "\n";
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <chrono>

using namespace std;

void binarySearch(vector<int>* arr, int* num, int* low, int* mid, int* high) {

	while (true) {

		if (arr->at(*mid) <= *num && arr->at(*mid + 1) > * num) {
			break;
		}
		else if (*num > arr->at(*mid)) {
			*low = *mid;
			*mid = (*low + *high) / 2;
		}
		else if (*num < arr->at(*mid)) {
			*high = *mid;
			*mid = (*high + *low) / 2;
		}

	}

}

void gcd(int* a, int* b, int* _gcd) {
	if (*a == *b) {
		*_gcd = *a;
	}
	else if ((*a % 2 == 0 && *b % 2 != 0) || (*a % 2 != 0 && *b % 2 == 0)) {
		*_gcd = 1;
	}
	else if (*a == 0 || *b == 0) {
		*_gcd = 1;
	}
	else if (*a > * b) {
		for (int i = 2; i < *a / 2; i++) {
			if (*a % i == 0 && *b % i == 0) {
				*_gcd *= i;
				*a /= i;
				*b /= i;
				i--;
			}
			if (*a == 1 || *b == 1) {
				break;
			}
		}
	}
	else if (*b > * a) {
		for (int i = 2; i < *b / 2; i++) {
			if (*a % i == 0 && *b % i == 0) {
				*_gcd *= i;
				*a /= i;
				*b /= i;
				i--;
			}
			if (*a == 1 || *b == 1) {
				break;
			}
		}
	}
}

void print(char* s, long long* size) {
	for (int i = *size - 1; i >= 0; i--) {
		cout << s[i];
	}
	cout << endl;
}

void _ceil(int* first, int* n) {

	if (*first % 4 == 0) {

		*n = *first / 4;

	}
	else {

		*n = *first / 4 + 1;

	}

}

void swap(long long* a, long long* b, long long* x, long long* y) {

	if (*a < *b) {

		long long* temp = new long long;

		*temp = *a;
		*a = *b;
		*b = *temp;

		*temp = *x;
		*x = *y;
		*y = *temp;

		delete temp;

	}

}

void firstWay(long long* a, long long* b, long long* x, long long* y, long long* n) {

	if (*b - *n >= *y) {

		*b = *b - *n;

	}

	else {

		*n = *n - (*b - *y);

		*b = *y;

		if (*a - *n >= *x) {

			*a = *a - *n;

		}

		else {

			*a = *x;

		}

	}

}

void secondWay(long long* a, long long* b, long long* x, long long* y, long long* n) {

	if (*n % 2 == 0) {

		if (*b - *n / 2 >= *y) {

			*b = *b - *n / 2;

			*n = *n / 2;

		}

		else {

			*n = *n - (*b - *y);

			*b = *y;

		}

		if (*a - *n >= *x) {

			*a = *a - *n;

			*n = 0;

		}

		else {

			*n = *n - (*a - *x);

			*a = *x;

		}

	}

	else {

		if (*b - *n / 2 - 1 >= *y) {

			*b = *b - *n / 2 - 1;

			*n = *n / 2 - 1;

		}

		else {

			*n = *n - (*b - *y);

			*b = *y;

		}

		if (*a - *n >= *x) {

			*a = *a - *n;

			*n = 0;

		}

		else {

			*n = *n - (*a - *x);

			*a = *x;

		}

	}

}

void thirdWay(long long* a, long long* b, long long* x, long long* y, long long* n) {

	if (*a - *n >= *x) {

		*a = *a - *n;

	}

	else {

		*n = *n - (*a - *x);

		*a = *x;

		if (*b - *n >= *y) {

			*b = *b - *n;

		}

		else {

			*b = *y;

		}

	}

}

int main()
{

	int* tests = new int;

	cin >> *tests;

	for (int h = 0; h < *tests; h++) {

		long long* a = new long long;
		long long* b = new long long;
		long long* x = new long long;
		long long* y = new long long;
		long long* n = new long long;

		cin >> *a >> *b >> *x >> *y >> *n;

		swap(a, b, x, y);

		long long* a1 = new long long(*a);
		long long* b1 = new long long(*b);
		long long* x1 = new long long(*x);
		long long* y1 = new long long(*y);
		long long* n1 = new long long(*n);

		long long* a2 = new long long(*a);
		long long* b2 = new long long(*b);
		long long* x2 = new long long(*x);
		long long* y2 = new long long(*y);
		long long* n2 = new long long(*n);

		long long* a3 = new long long(*a);
		long long* b3 = new long long(*b);
		long long* x3 = new long long(*x);
		long long* y3 = new long long(*y);
		long long* n3 = new long long(*n);

		firstWay(a1, b1, x1, y1, n1);

		secondWay(a2, b2, x2, y2, n2);

		thirdWay(a3, b3, x3, y3, n3);

		*a1 = *a1 * *b1;
		*a2 = *a2 * *b2;
		*a3 = *a3 * *b3;

		if (*a1 > * a2) {

			if (*a3 > * a2) {

				cout << *a2 << endl;

			}

			else {

				cout << *a3 << endl;

			}

		}

		else {

			if (*a3 > * a1) {

				cout << *a1 << endl;

			}

			else {

				cout << *a3 << endl;

			}

		}

		delete a, b, x, y, n, a1, b1, x1, y1, n1, a2, b2, x2, y2, n2, a3, b3, x3, y3, n3;

	}

	delete tests;

}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "A", "A\A.vcxproj", "{A69E8302-6895-4EBE-8F4C-94E3707A7B17}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Debug|x64.ActiveCfg = Debug|x64
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Debug|x64.Build.0 = Debug|x64
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Debug|x86.ActiveCfg = Debug|Win32
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Debug|x86.Build.0 = Debug|Win32
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Release|x64.ActiveCfg = Release|x64
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Release|x64.Build.0 = Release|x64
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Release|x86.ActiveCfg = Release|Win32
		{A69E8302-6895-4EBE-8F4C-94E3707A7B17}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {00AA2A4D-94C2-4779-9364-089B8FB4B79A}
	EndGlobalSection
EndGlobal


// A.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>

using namespace std;

typedef long long int li;
typedef unsigned long long int lli;

const lli MAX_N = 1e6 + 1;
const lli MOD = 1e9 + 7;
const lli INF = 1e9;
const lli LINF = 1e18;
const lli N = 100001;

void snake_bite()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed;
}

// ::Modular arithmetic::

//lli factorialNumInverse[N + 1];
//lli naturalNumInverse[N + 1];
//lli fact[N + 1];
//
//void InverseofNumber(lli p)
//{
//    naturalNumInverse[0] = naturalNumInverse[1] = 1;
//    for (int i = 2; i <= N; i++)
//        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
//}
//
//void InverseofFactorial(lli p)
//{
//    factorialNumInverse[0] = factorialNumInverse[1] = 1;
//    for (int i = 2; i <= N; i++)
//        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
//}
//
//void factorial(lli p)
//{
//    fact[0] = 1;
//    for (int i = 1; i <= N; i++) {
//        fact[i] = (fact[i - 1] * i) % p;
//    }
//}
//
//lli nCr(lli n, lli R, lli p)
//{
//    lli ans = ((fact[n] * factorialNumInverse[R])
//        % p * factorialNumInverse[n - R])
//        % p;
//    return ans;
//}
//
//long long binpow(long long a, long long b) {
//    a %= MOD;
//    long long res = 1;
//    while (b > 0) {
//        if (b & 1)
//            res = res * a % MOD;
//        a = a * a % MOD;
//        b >>= 1;
//    }
//    return res;
//}

lli modulus(lli a, lli b)
{
    if (b - a < 0)
        return a - b;
    return b - a;
}
void solve()
{
    lli a, b,x, y, n;
    cin >> a >> b >> x >> y >> n;
    lli m = 2;
    lli prod = LINF;
    while (m--)
    {
        lli da = min(a - x, n);
        lli db = min(b - y, n - da);
        lli ans = (a - da) * (b - db);
        prod = min(prod, ans);
        /*cout << "da = " << da << "  ,db = " << db << " ,ans = " << ans << " ,prod = " << prod <<endl;*/
        swap(a, b);
        swap(x, y);
    }

    cout << prod;
}

int main()
{
    snake_bite();
    /*InverseofNumber(MOD);
    InverseofFactorial(MOD);
    factorial(MOD);*/
    lli t;
    cin >> t;
    //t = 1;
    while (t--)
    {
        solve();
        cout << endl;
    }
    //std::cout << "Hello World!\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int ll
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
int read()
{
	int w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}
//------------------------ 以上是我常用模板与刷题几乎无关 ------------------------//
int cmp(int a, int b, int x, int y, int n)
{
	int cnt = 0;
	if ((a - x) + (b - y) < n)
		return x * y;

	if (b - y <= n)
	{
		cnt += b - y;
		b = y; // b = b - cnt;
	}
	else
	{
		// cnt += n;
		b = b - n;
		return a * b;
	}

	if (a - x >= n - cnt)
	{
		// cnt += a - x;
		a = a - (n - cnt);
		return a * b;
	}

	// else
	// {
	// 	a = a - (n - cnt);
	// 	cnt += n - cnt;
	// 	return a * b;
	// }
}
signed main()
{
	int t = read();
	while (t--)
	{
		int a, b, x, y, n;
		scanf("%lld%lld%lld%lld%lld", &a, &b, &x, &y, &n);
		int res1 = cmp(a, b, x, y, n);
		int res2 = cmp(b, a, y, x, n);
		if (res1 > res2)
			printf("%lld\n", res2);
		else
			printf("%lld\n", res1);
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int ll
#define ll ;long long
#define INF 0x3f3f3f3f
using namespace std;
int read()
{
	int w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}
//------------------------ 以上是我常用模板与刷题几乎无关 ------------------------//
signed main()
{
	int t = read();
	while(t--)
	{
		int a, b, x, y, n;
		scanf("%lld%lld%lld%lld%lld", &a, &b, &x, &y, &n)
		int cnt = 0;
		if((a - x) + (b - y) < n)
		{
			printf("%lld\n", x * y);
			continue;
		}
		if(b - y <= n)
		{
			cnt += b - y;
			b = b - cnt;
		}
		else
		{
			cnt += n;
			b = b - n;
			printf("%lld\n", a * b);
			continue;
		}
		if(a - x <= n - cnt)
		{
			cnt += a - x;
			a = a - (n - cnt);
			printf("%lld\n", a * b);
		}
		else
		{
			a = a - (n - cnt);
			cnt += n - cnt;
			printf("%lld\n",a * b);
		}
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int ll
#define ll ;long long
#define INF 0x3f3f3f3f
using namespace std;
int read()
{
	int w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}
//------------------------ 以上是我常用模板与刷题几乎无关 ------------------------//
signed main()
{
	int t = read();
	while(t--)
	{
		int a, b, x, y, n;
		scanf("%lld%lld%lld%lld%lld", &a, &b, &x, &y, &n)
		int cnt = 0;
		if((a - x) + (b - y) < n)
		{
			printf("%lld\n", x * y);
			continue;
		}
		if(a < b)
			swap(a, b);
		if(x < y)
			swap(x, y);
		if(b - y <= n)
		{
			cnt += b - y;
			b = b - cnt;
		}
		else
		{
			cnt += n;
			b = b - n;
			printf("%lld\n", a * b);
			continue;
		}
		if(a - x <= n - cnt)
		{
			cnt += a - x;
			a = a - (n - cnt);
			printf("%lld\n", a * b);
		}
		else
		{
			a = a - (n - cnt);
			cnt += n - cnt;
			printf("%lld\n",a * b);
		}
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int ll
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
int read()
{
	int w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}
//------------------------ 以上是我常用模板与刷题几乎无关 ------------------------//
int cmp(int a, int b, int x, int y, int n)
{
	int cnt = 0;
	if((a - x) + (b - y) < n)
		return x * y;

	if(b - y <= n)
	{
		cnt += b - y;
		b = b - cnt;
	}
	else
	{
		cnt += n;
		b = b - n;
		return a * b;
	}

	if(a - x <= n - cnt)
	{
		cnt += a - x;
		a = a - (n - cnt);
		return a * b;
	}
	else
	{
		a = a - (n - cnt);
		cnt += n - cnt;
		return a * b;
	}
}
signed main()
{
	int t = read();
	while(t--)
	{
		int a, b, x, y, n;
		scanf("%lld%lld%lld%lld%lld", &a, &b, &x, &y, &n);
		int res1 = cmp(a, b, x, y, n);
		int res2 = cmp(b, a, y, x, n);
		if(res1 > res2)
			printf("%lld\n", res2);
		else
			printf("%lld\n", res1);
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define int ll
#define INF 0x3f3f3f3f
using namespace std;
int read()
{
	int w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}
//------------------------ 以上是我常用模板与刷题几乎无关 ------------------------//
signed main()
{
	int t = read();
	while(t--)
	{
		int a, b, x, y, n;
		cin >> a >> b >> x >> y >> n;
		int cnt = 0;
		if(a < b)
			swap(a, b);
		if(x < y)
			swap(x, y);
		while(cnt < n && b > y)
		{
			b--;
			cnt++;
		}
		while(cnt < n && a > x)
		{
			a--;
			cnt++;
		}
		printf("%lld\n",a * b);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;
typedef unsigned long long int ll;

void solution(ll a, ll b, ll x, ll y, ll n);
ll lim(ll number, ll Lm, ll n);

int main()
{

	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		ll a, b, x, y, n;
		cin >> a >> b >> x >> y >> n;
		if (lim(b,y,n)<lim(a,x,n)) solution(b, a, y, x, n); else solution(a, b, x, y, n);
	}
	return 0;
}

void solution(ll a, ll b, ll x, ll y, ll n) {

	if (a - x < n) {
		ll a0 = a;
		a = x;
		if (b - y < n - a0 + x) b = y; else b -= n - a0 + x;
	}
	else a -= n;
	cout << a * b << "\n" ;
}

ll lim(ll number, ll Lm, ll n) {
	ll rtrn;
	if (n >= number - Lm) rtrn = Lm; else rtrn = number - n;
	return rtrn;
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

void solution(int a, int b, int x, int y, int n);
int lim(int number, int Lm, int n);

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; i++) {
		int a, b, x, y, n;
        scanf("%d %d %d %d %d", &a, &b, &x, &y, &n);
		if (lim(b,y,n)<lim(a,x,n)) solution(b, a, y, x, n); else solution(a, b, x, y, n);
	}
	return 0;
}

void solution(int a, int b, int x, int y, int n) {

	if (a - x <= n) {
		int a0 = a;
		a = x;
		if (b - y <= n) b = y; else b -= n - a0 + x;
	}
	else a -= n;
	cout << a * b;
}

int lim(int number, int Lm, int n) {
	int rtrn;
	if (n >= number - Lm) rtrn = Lm; else rtrn = number - n;
	return rtrn;
}


#include <iostream>
using namespace std;

int main(){
long long int t;
cin>>t;

while(t--){
    long long int a , b , c ,  d , n;
    long long int i , j;
    cin>>a>>b>>c>>d>>n;
    if(b > a){
       swap(a , b);
    }
if(b - n >= d){
    i = (b - n)*a;
}
else{
 if(a - n + b - d >= c){
 i = (d)*(a - n + b - d);
 }
else{
    i = c*d;
}
}

if(a - n >= c)
{
j = (a - n)*b;
}
else{
   if(b - n + a - c >= d)
   {
       j = (c)*(b - n + a - c);
   }
   else{
    j = c*d;
   }
}

if(i>j){
    cout<<j<<"\n";
}
else{
    cout<<i<<"\n";
}

}

return 0;
}


#include <iostream>
using namespace std;

int main(){
long long int t;
cin>>t;

while(t--){
    long long int a , b , c ,  d , n;
    long long int i , j;
    cin>>a>>b>>c>>d>>n;

if(b - n >= d){
    i = (b - n)*a;
}
else{
 if(a - n + b - d >= c){
 i = (d)*(a - n + b - d);
 }
else{
    i = c*d;
}
}

if(a - n >= c)
{
j = (a - n)*b;
}
else{
   if(b - n + a - c >= d)
   {
       j = (c)*(b - n + a - c);
   }
   else{
    j = c*d;
   }
}

if(i>j){
    cout<<j<<"\n";
}
else{
    cout<<i<<"\n";
}

}

return 0;
}


#include <iostream>
using namespace std;

int main(){
long long int t;
cin>>t;

while(t--){
    long long int a , b , c ,  d , n;
    long long int i , j;
    cin>>a>>b>>c>>d>>n;
    if(b > a){
       swap(a , b);
    }
if(b - n >= d){
    i = (b - n)*a;
}
else{
 if(a - n + b - d >= c){
 i = (d)*(a - n + b - d);
 }
else{
    i = c*d;
}
}

if(a - n >= c)
{
j = (a - n)*b;
}
else{
   if(b - n + a - c >= d)
   {
       j = (c)*(b - n + a - c);
   }
   else{
    j = c*d;
   }
}

cout<<min(i , j)<<"\n";
}

return 0;
}


// codeforces B. Minimum Product.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>

int main()
{
    int test_case = 0;
    std::cin >> test_case;
    for (int i = 0; i < test_case; i++) {
        long long a, b, x, y, n;
        std::cin >> a >> b >> x >> y >> n;

        long long res = 0;

        if (a - x >= n && b - y >= n) {
            if (a <= b) {
                a -= n;
            }
            else {
                b -= n;
            }
            res = a * b;
            std::cout << res << std::endl;
        }
        else if (a - x < n && b - y < n) {
            if ((a - x) + (b - y) <= n) {
                res = x * y;
                std::cout << res << std::endl;
            }
            else {
                if (x <= y) {
                    res = x * (b - (n - (a - x)));
                    std::cout << res << std::endl;
                }
                else {
                    res = y * (a - (n - (b - y)));
                    std::cout << res << std::endl;
                }
            }
        }
        else {
            if ((a - x) >= n) {
                if ((a - n) <= y) {
                    res = (a - n) * b;
                    std::cout << res << std::endl;
                }
                else {
                    res = y * (a - (n - (b - y)));
                    std::cout << res << std::endl;
                }
            }
            else {
                if ((b - n) <= x) {
                    res = a * (b - n);
                    std::cout << res << std::endl;
                }
                else {
                    res = x * (b - (n - (a - x)));
                    std::cout << res << std::endl;
                }
            }
        }
    }
    return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int testCount;
    std::cin >> testCount;

    std::vector<unsigned long long> resultList;

    long long a, b, x, y, operations;
    long long resA, resB, remainingOperations, firstTry, secondTry;
    for (int i = 0; i < testCount; i++)
    {
        std::cin >> a >> b >> x >> y >> operations;

        remainingOperations = operations;
        resA = std::max(x, a - remainingOperations);
        remainingOperations -= a - resA;
        resB = std::max(y, b - remainingOperations);
        firstTry = resA * resB;

        remainingOperations = operations;
        resB = std::max(y, b - remainingOperations);
        remainingOperations -= b - resB;
        resA = std::max(x, a - remainingOperations);
        secondTry = resA * resB;

        resultList.push_back(std::min( firstTry, secondTry ));
    }

    for (int i = 0; i < resultList.size(); i++)
    {
        std::cout << resultList[i] << std::endl;
    }

}


#include <iostream>
#include <cstdio>
using namespace std;
long long a,b,x,y,n,t,j,k,n1,n2;
int main(){
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>a>>b>>x>>y>>n;
        if(a-n<x){
            n1=n-(a-x);
            j=x;
        }
        else{
            j=a-n;
        }
        if(b-n<y){
            n2=n-(b-y);
            k=y;
        }
        else{
            k=b-n;
        }
        if(j<=k){
            if(b-n1<y)
                b=y;
            else
                b-=n1;
            cout<<j*b<<"\n";
        }
        else{
            if(a-n2<x)
                a=x;
            else
                a-=n2;
            cout<<k*a<<"\n";
        }
        n1=0;
        n2=0;
    }
}


#include <iostream>
#include <cstdio>
using namespace std;
long long a,b,x,y,n,t;
int main(){
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>a>>b>>x>>y>>n;
        if(a < b){
            //cout<<1<<endl;
            if(a-n<x){
                n=n-(a-x);
                a=x;
                if(b-n<y)
                    b=y;
                else
                    b-=n;
            }
            else{
                a-=n;
            }
        }
        else if(a > b){
            //cout<<2<<endl;
            if(b-n<y){
                n=n-(b-y);
                b=y;
                if(a-n<x)
                    a=x;
                else
                    a-=n;
            }
            else{
                b-=n;
            }
        }
        else{
            //cout<<3<<endl;
            if(a<=b){
                if(a-n<x){
                    n=n-(a-x);
                    a=x;
                    if(b-n<y)
                        b=y;
                    else
                        b-=n;
                }
                else{
                    a-=n;
                }
            }
            else{
                if(b-n<y){
                    n=n-(b-y);
                    b=y;
                    if(a-n<x)
                        a=x;
                    else
                        a-=n;
                }
                else{
                    b-=n;
                }
            }
        }
        cout<<a*b<<"\n";
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int _;
	cin >> _;
	while (_--) {
		long long int a, b, x, y, n;
		cin >> a >> b >> x >> y >> n;

		long long int res1, res2, a1 = a, a2 = a, b1 = b, b2 = b, n1 = n, n2 = n;

		long long int tmp1 = b1;
		b1 = max(y, b1 - n1);
		n1 -= (tmp1 - b1);
		a1 = max(x, a1 - n1);
		res1 = a1 * b1;

		long long int tmp2 = a2;
		a2 = max(x, a2 - n2);
		n2 -= (tmp2 - a2);
		b2 = max(y, b2 - n2);
		res2 = a2 * b2;

		cout << min(res1, res2) << endl;

	}
 return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int _;
	cin >> _;
	while (_--) {
		long long int a, b, x, y, n;
		cin >> a >> b >> x >> y >> n;

		long long int res1, res2, a1 = a, a2 = a, b1 = b, b2 = b, n1 = n, n2 = n;

		long long int tmp1 = b1;
		b1 = max(y, b1 - n1);
		n1 -= (tmp1 - b1);
		a1 = max(x, a1 - n1);
		res1 = a1 * b1;

		long long int tmp2 = a2;
		a2 = max(y, a2 - n2);
		n2 -= (tmp2 - a2);
		b2 = max(x, b2 - n2);
		res2 = a2 * b2;

		cout << min(res1, res2) << endl;

	}
 return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int _;
	cin >> _;
	while (_--) {
		long long int a, b, x, y, n;
		cin >> a >> b >> x >> y >> n;

		long long int res1, res2, a1 = a, a2 = a, b1 = b, b2 = b, n1 = n, n2 = n;

		int tmp1 = b1;
		b1 = max(y, b1 - n1);
		n1 -= (tmp1 - b1);
		a1 = max(x, a1 - n1);
		res1 = a1 * b1;

		int tmp2 = a2;
		a2 = max(y, a2 - n2);
		n2 -= (tmp2 - a2);
		b2 = max(x, b2 - n2);
		res2 = a2 * b2;

		cout << min(res1, res2) << endl;

	}
 return 0;
}


#include <stdio.h>
#include <algorithm>

using namespace std;

int t;
typedef long long ll;
ll a, b, x, y, n;

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%lld %lld %lld %lld %lld", &a, &b, &x, &y, &n);
		ll na = max(a - n, x), nb = max(b - n, y);
		if (na > nb) n -= b - nb, b = nb, a = max(a - n, x);
		else n -= a - na, a = na, b = max(b - n, y);
		printf("%lld\n", a * b);
	}
	return 0;
}


    #include <iostream>
    #include <algorithm>

    using namespace std;

    int main(){

    	int k, a, b, x, y, n;

    	cin >> k;
    	for(int i = 0;i < k;i++)
    	{
    		cin >> a >> b >> x >> y >> n;
    		long long ans = 1e18;
    		for (int j = 0;j < 2;j++)
    		{
    			int delA = min(a - x, n);
    			int delB = min(n - delA, b - y);
    			ans = min(ans, (a - delA) * 1ll * (b - delB));
    			swap(a, b);
    			swap(x, y);
    		}
    		cout << ans <<"\n";
    	}

    }


#include <iostream>
using namespace std;
void test() {
	long long a, b, x, y, n;
	cin >> a >> b >> x >> y >> n;

	if (a < b) { swap(a, b); swap(x, y); }	//so a is always > b

	if ((y>x)&&(n>(b-y))){
		a -= n; n = 0;
		if (a < x) { n = x - a; a = x; }
		b -= n;
		if (b < y) { b = y; }
	}
	else {
		b -= n; n = 0;
		if (b < y) { n = y - b; b = y; }
		a -= n;
		if (a < x) { a = x; }
	}

	cout <<(a * b) << endl;;
}

int main()
{
	int k=0;
	cin >> k;
	for (int i = 0; i < k; i++)
		test();
}


#include <iostream>
#include <algorithm>
using namespace std;
void testb() {
	long long a, b, x, y, n, ost;
	cin >> a >> b >> x >> y >> n;

	if (x < y) { swap(a, b); swap(x, y); }	//so x is always > y
	ost = -(-a + x - b + y) - n;

	x += ost; ost = 0;
	if (x > a) { ost = x - a; x = a; }
	y += ost;

	cout << (x * y) << endl;;
}
void printArr(long long start, long long step, long long n) {
	for (long long i = 0; i < n; i++) {
		cout << (start);
		start += step;
		if (i+1 < n) cout << ' ';
	}
	cout << endl;
}
bool isPrimeNumber(long long n,long long& min) {
	for (long long i = min; i < n/2; i++) {
		if (n % i == 0) { min = i; return false; }
	}
	return true;
}
void testc() {
	long long n, x, y;
	cin >> n>> x>> y;
	/*if (y-x < n) {
		printArr(y - n+1, 1, n);
		return;
	}
	long long dif = y - x;
	long long step=2;
	if (isPrimeNumber(dif,step))
	{
		long long start = max(x - dif * (min(n - 2, x / dif)),x%dif);
		printArr(start, dif, n);
		return;
	}*/
	int dif = y - x;
	for (int step = 1; step <= dif; step++) {
		if (dif % step == 0 && (dif / step < n)) {
			printArr(max(y-step*(n-1),x%step==0?step: x % step),step,n);
			return;
		}
	}

}

void subNdis(long long& a, long long& x, long long& b, long long& y,  long long& n) {
	a -= n;
	if (a < x) { b -= x - a; a = x; }
}

void test() {
	long long a, b, x, y, n;
	cin >> a >> b >> x >> y >> n;
	if (a > b) { swap(a, b); swap(x, y); }	//a < b
	long long da = a - x;
	long long db = b - y;
	if (n >= (da + db)) {
		cout << x * y << endl;
		return;
	}

	long long a1 = a, b1 = b;

	subNdis(a1, x, b1, y, n);
	subNdis(b, y, a, x, n);

	cout << min((a * b),(a1)*(b1)) << endl;
}

int main()
{
	int k=0;
	cin >> k;
	for (int i = 0; i < k; i++)
		test();
}


#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) {
        long a, b, x, y, n, a1 = 0, b1 = 0, n1 = 0, n2 = 0, a2 = 0, b2 = 0;
        cin >> a >> b >> x >> y >> n;
        long z = 0;
        a2 = a;
        a1 = a;
        b2 = b;
        b1 = b;
        n1 = n;
        n2 = n;

        a1 = max(a - n, x);
        n1 -= (a - a1);
        if (n1 < 0)n1 = 0;
        b1 = max(y, b - n1);

        b2 = max(b - n, y);
        n2 -= (b - b2);
        if (n2 < 0)n2 = 0;
        a2 = max(x, a - n2);

        if (a1 * b1 < a2 * b2)cout << (long long)a1 * b1;
        else cout << (long long)a2 * b2;

        cout << "\n";

    }
    return 0;
}


#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) {
        long long a, b, x, y, n, a1 = 0, b1 = 0, n1 = 0, n2 = 0, a2 = 0, b2 = 0;
        cin >> a >> b >> x >> y >> n;
        a2 = a;
        a1 = a;
        b2 = b;
        b1 = b;
        n1 = n;
        n2 = n;

        a1 = max(a - n, x);
        n1 -= (a - a1);
        if (n1 < 0)n1 = 0;
        b1 = max(y, b - n1);

        b2 = max(b - n, y);
        n2 -= (b - b2);
        if (n2 < 0)n2 = 0;
        a2 = max(x, a - n2);

        cout << min(a1 * b1, a2 * b2) << "\n";

    }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--) {
		long long a, b, x, y, n;
		cin >> a >> b >> x >> y >> n;
		long long aMin = max(x, a - n);
		long long bMin = max(y, b - n);
		long long ans = aMin * max(y, b - n + a - aMin);
		ans = min(ans, bMin * max(x, a - n + b - bMin));
		cout << ans << "\n";
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int a,b,t;
	scanf("%d",&t);
	while(t--){
		scanf("%d %d",&a,&b);
		if(abs(a-b)%10==0){
			printf("%d\n",abs(a-b)/10);
		}else{
			printf("%d\n",abs(a-b)/10+1);
		}
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,x,y,n,t;
	scanf("%d",&t);
	while(t--){
		scanf("%lld %lld %lld %lld %lld",&a,&b,&x,&y,&n);
		printf("%lld\n",min( max(x,a-n) * max(y,b - (n - (a - max(x,a - n)))),max(y,b - n) * max(x,a - (n - (b - max(y,b - n))))) );
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,x,y,n;
	int t;
	scanf("%d",&t);
	while(t--){
		scanf("%lld %lld %lld %lld %lld",&a,&b,&x,&y,&n);
		printf("%lld\n",min( max(x,a-n) * max(y,b - (n - (a - max(x,a - n)))),max(y,b - n) * max(x,a - (n - (b - max(y,b - n))))) );
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);
    cout.tie(0);

    long long t, a, b, x, y, n;
    cin >> t;

    long long s, k;

    for(long long i = 0; i < t; i++){

        cin >> a >> b >> x >> y >> n;

        if(a - x + b - y < n){
            cout << x * y << endl;
        }else{
            if(a - n >= x){
                s = (a - n) * b;
            }else{
                s = x * (b - (n - a + x));
            }
            if(b - n >= y){
                k = (b - n) * a;
            }else{
                k = x * (a - (n - b + y));
            }
            if(s < k){
                cout << s << endl;
            }else{
                cout << k << endl;
            }
        }
    }
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);
    cout.tie(0);

    long long t, a, b, x, y, n;
    cin >> t;

    long long s, k;

    for(long long i = 0; i < t; i++){

        cin >> a >> b >> x >> y >> n;

        if(a - x + b - y < n){
            cout << x * y << endl;
        }else{
            if(a - n >= x){
                s = (a - n) * b;
            }else{
                s = x * (b - (n - a + x));
            }

            if(b - n >= y){
                k = (b - n) * a;
            }else{
                k = y * (a - (n - b + y));
            }
            if(s < k){
                cout << s << endl;
            }else{
                cout << k << endl;
            }
        }
    }
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
ll t, a, b, x, y, n;
int main(void) {
	scanf("%d", &t);
	while (t--) {
		ll ans = 1e20;
		scanf("%lld%lld%lld%lld%lld", &a, &b, &x, &y, &n);
		ll mA = a - x;
		ll mB = b - y;
		if (mA + mB < n) {
			ans = (x * y);
		}
		else {
			if (mA > mB) {
				swap(a, b);
				swap(mA, mB);
				swap(x, y);
			}
			if (mA > n) {
				mA = a - n;
				mB = b;
			}
			else {
				mB = n - mA;
				mB = b - mB;
				mA = x;
			}
			while (mA != a + 1) {
				ll sum = mA * mB;
				if (sum > ans)break;
				ans = min(ans, sum);
				mA += 1;
				mB -= 1;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
ll t, a, b, x, y, n;
int main(void) {
	scanf("%lld", &t);
	while (t--) {
		ll ans = 1e20;
		scanf("%lld%lld%lld%lld%lld", &a, &b, &x, &y, &n);
		ll mA = a - x;
		ll mB = b - y;
		if (mA + mB <= n) {
			ans = (x * y);
		}
		else {
			if (mA >= n) {
				mA = a - n;
				mB = b;
			}
			else {
				mB = n - mA;
				mB = b - mB;
				mA = x;
			}
			if (mB < y)mB = y;
			ans = mA * mB;
			mA = a - x;
			mB = b - y;
			swap(a, b);
			swap(mA, mB);
			swap(x, y);
			if (mA >= n) {
				mA = a - n;
				mB = b;
			}
			else {
				mB = n - mA;
				mB = b - mB;
				mA = x;
			}
			if (mB < y)mB = y;
			ans = min(ans, mA * mB);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
const long long inf = 1e18 + 1;
const long long mod = 1e9;

int main() {
	long long a, b, c, d, x, y, n, t, mas[10];
	cin >> t;
	for (int u = 1; u <= t; u++) {
		long long ans1 = inf, ans2 = inf, ans3 = inf, ans4 = inf, ans5 = inf, ans6 = inf;
		cin >> mas[1] >> mas[2] >> mas[3] >> mas[4] >> mas[5];
		a = mas[1];
		b = mas[2];
		x = mas[3];
		y = mas[4];
		n = mas[5];
		if (n <= a - x) {
			a -= n;
			ans1 = a * b;
		}
		else {
			n -= (a - x);
			a = x;
			if (n <= b - y) {
				b -= n;
				ans2 = a * b;
			}
			else {
				b = y;
				ans3 = a * b;
			}
		}
		a = mas[1];
		b = mas[2];
		x = mas[3];
		y = mas[4];
		n = mas[5];
		if (n <= b - y) {
			b -= n;
			ans4 = a * b;
		}
		else {
			n -= (b - y);
			b = y;
			if (n <= a - x) {
				a -= n;
				ans5 = a * b;
			}
			else {
				a = x;
				ans6 = a * b;
			}
		}
		cout << min(min(ans1, ans2), min(ans3, min(ans4, min(ans5, ans6)))) << endl;
	}
}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
const long long inf = 1e12;
const long long mod = 1e9;

int main() {
	long long a, b, c, d, x, y, n, t;
	pair<long long, long long>maxx, minn;
	cin >> t;
	for (int u = 1; u <= t; u++) {
		bool out = 0;
		cin >> a >> b >> x >> y >> n;
		if (a > b) maxx = { a, x };
		else if (a == b) {
			if (x > y) maxx = { a, x };
			else maxx = { b, y };
		}
		else maxx = { b, y };
		if (a < b) minn = { a, x };
		else if (a == b) {
			if (x < y) minn = { a, x };
			else minn = { b, y };
		}
		else minn = { b, y };
		c = minn.first - minn.second;
		if (c >= n) {
			cout << maxx.first * (minn.first - n) << endl;
			out = 1;
		}
		else n -= c;
		if (out == 0) {
			d = maxx.first - maxx.second;
			if (d >= n) {
				cout << (maxx.first - n) * (minn.first - c) << endl;
				out = 1;
			}
			else cout << (maxx.first - d) * (minn.first - c) << endl;
		}
	}
}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
const long long inf = 1e12;
const long long mod = 1e9;

int main() {
	long long a, b, c, d, x, y, n, t;
	pair<long long, long long>maxx, minn;
	cin >> t;
	for (int u = 1; u <= t; u++) {
		bool out = 0;
		cin >> a >> b >> x >> y >> n;
		if (a > b) maxx = { a, x };
		else if (a == b) {
			if (x > y) maxx = { a, x };
			else maxx = { b, y };
		}
		else maxx = { b, y };
		if (a < b) minn = { a, x };
		else if (a == b) {
			if (x < y) minn = { a, x };
			else minn = { b, y };
		}
		else minn = { b, y };
		if (maxx.first - maxx.second >= n) {
			cout << (maxx.first - n) * minn.first;
			out = 1;
		}
		if (out == 0) {
			c = minn.first - minn.second;
			if (c >= n) {
				cout << maxx.first * (minn.first - n) << endl;
				out = 1;
			}
			else n -= c;
			if (out == 0) {
				d = maxx.first - maxx.second;
				if (d >= n) {
					cout << (maxx.first - n) * (minn.first - c) << endl;
					out = 1;
				}
				else cout << (maxx.first - d) * (minn.first - c) << endl;
			}
		}
	}
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;

int main() {
	int t;
	cin >> t;
	ll a, b, x, y, n;
	ll ans;
	for (int i = 0; i < t; i++) {
		cin >> a >> b >> x >> y >> n;
		ans = INT64_MAX;
		if (b - y + a - x <= n) {
			cout << x * y << endl;
			continue;
		}
		if (a - x >= n)ans = min(ans, (a - n) * b);
		else {
			ans = min(ans, x * (b - n + a - x));
		}
		if (b - y >= n) ans = min(ans, a * (b - n));
		else ans = min(ans, y * (a - n + b - y));
		cout << ans << endl;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;

int main() {
	int t;
	cin >> t;
	ll a, b, x, y, n;
	ll ans;
	for (int i = 0; i < t; i++) {
		cin >> a >> b >> x >> y >> n;

		if (b - y + a - x <= n)cout << x * y << endl;
		else {
			if (a < b) {
				swap(a, b);
				swap(x, y);
			}
			if (n > b - y && a - b <= n) {
				n = n - (a - b);
				a = b;
			}
			if (a == b) {
				if (x < y)swap(x, y);
			}

			if (n <= b - y) {
				ans= (b - n) * a ;
			}
			else if (a - b > n || a == b) {
				ans = y * (a - n + b - y);
			}
			cout << ans << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;

int main() {
	int t;
	cin >> t;
	int a, b,x,y,n;
	for (int i = 0; i < t; i++) {
		cin >> a >> b >> x >> y >> n;

		if (b - y + a - x <= n)cout << x * y << endl;
		else{
			if (a < b) {
				swap(a, b);
				swap(x, y);
			}
			if (n > b - y && a - b <= n) {
				n = n - (a - b);
				a = b;
			}
			if (a == b) {
				if (x < y)swap(x, y);
			}

			if (n <= b - y) {
				cout << (ll)(b - n) * a << endl;
			}
			else if (a - b > n||a==b) {
				cout << (ll)y * (a - n + b - y) << endl;
			}
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <clocale>
#include <fstream>
#include <sstream>
#include <iterator>
using namespace std;

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

const int mod = 1e9 + 7;

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0)
		if (b & 1) {
			res = (long long)(res * 1ll * a);//% mod;
			--b;
		}
		else {
			a = (long long)(a * 1ll * a);//% mod;
			b >>= 1;
		}
	return (long long)res;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//cout.precision(16); cout.setf(ios::fixed);
	int q;
	cin >> q;
	while (q--)
	{
		int a, b, x, y;
		int n;
		cin >> a >> b >> x >> y>>n;
		/*if (a > b)
		{
			if(b-y>=n)

		}
		else {
			if (a == b)
			{
				if (x > y)
				{
					swap(a, b);
					swap(x, y);
				}
			}*/
		//}
		int n1 = n;
		int a1 = a, b1 = b;
		int x1 = x, y1 = y;
		if (a - x > b - y)
		{
			int mini = min(a - x, n);
			a -= mini;
			n -= mini;
			mini = min(b - y, n);
			b -= mini;
		}
		else {
			int mini = min(b - y, n);
			n -= mini;
			b -= mini;
			mini = min(a - x, n);
			a -= mini;
		}

		if (a1 - x1 < b1 - y1)
		{
			int mini = min(a1 - x1, n1);
			a1 -= mini;
			n1 -= mini;
			mini = min(b1 - y1, n1);
			b1 -= mini;
		}
		else {
			int mini = min(b1 - y1, n1);
			n1 -= mini;
			b1 -= mini;
			mini = min(a1 - x1, n1);
			a1 -= mini;
		}

		cout << min(a * 1ll * b,a1*1ll*b1) << endl;

	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <clocale>
#include <fstream>
#include <sstream>
#include <iterator>
using namespace std;

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

const int mod = 1e9 + 7;

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0)
		if (b & 1) {
			res = (long long)(res * 1ll * a);//% mod;
			--b;
		}
		else {
			a = (long long)(a * 1ll * a);//% mod;
			b >>= 1;
		}
	return (long long)res;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//cout.precision(16); cout.setf(ios::fixed);
	int q;
	cin >> q;
	while (q--)
	{
		int a, b, x, y;
		int n;
		cin >> a >> b >> x >> y >> n;
		/*if (a > b)
		{
			if(b-y>=n)

		}
		else {
			if (a == b)
			{
				if (x > y)
				{
					swap(a, b);
					swap(x, y);
				}
			}*/
			//}
		int n1 = n;
		int a1 = a, b1 = b;
		int x1 = x, y1 = y;

			int mini = min(a - x, n);
			a -= mini;
			n -= mini;
			mini = min(b - y, n);
			b -= mini;

			/*mini = min(b - y, n);
			n -= mini;
			b -= mini;
			mini = min(a - x, n);
			a -= mini;*/

			mini = min(b1 - y1, n1);
			n1 -= mini;
			b1 -= mini;
			mini = min(a1 - x1, n1);
			a1 -= mini;
/*
			mini = min(a1 - x1, n1);
			a1 -= mini;
			n1 -= mini;

			mini = min(b1 - y1, n1);
			b1 -= mini;*/
		cout << min(a * 1ll * b, a1 * 1ll * b1) << endl;

	}
	return 0;
}


#include <stdio.h>
#include<iostream>
#include<deque>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int t;long long int a, b, x, y, n;long long int left_num, right_num;
vector<long long int>v;

int main()
{
	cin >> t;

	while (t--)
	{
		cin >> a >> b >> x >> y >> n;
		if (n > (a - x) + (b - y))
		{
			left_num = x*y;
			v.push_back(left_num);
			continue;
		}

		if (a - x >= n)
		{
			left_num = (a - n) * b;
		}
		else//(a - x < n)
		{
			left_num = x * (b - (n - (a - x)));
		}

		if (b - y >= n)
		{
			right_num = (b - n) * a;
		}
		else
		{
			right_num = y * (a - (n - (b - y)));
		}
		v.push_back(min(right_num, left_num));
	}

	for (auto c : v)
	{
		cout << c << endl;
	}
}


/*
URL_HERE
*/
/*

*/
#ifdef _WIN32
#pragma warning(disable:4996)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <queue>
#include <iostream>
using namespace std;

FILE* _fin = stdin;
FILE* _fout = stdout;
#define PI 3.141592653589793238462643383279502884197169399375105820974
#define ten5p1 100001
#define ten6p1 1000001
#define ten8p1 100000001
#define ten9p1 1000000001
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define rep(var,n) for(int var=0;var<n;++var)
#define repi(n) rep(i,n)
#define repj(n) rep(j,n)
#define repi1(n) for(int i=1;i<n;++i)
#define repj1(n) for(int j=1;j<n;++j)
int _min(int a, int b) { return a <= b ? a : b; }
int _min(ll a, ll b) { return a <= b ? a : b; }
int _max(int a, int b) { return a >= b ? a : b; }
ll _max(ll a, ll b) { return a >= b ? a : b; }
void zero(int* data, int n) { memset(data, 0, sizeof(int) * n); }
void zero(ll* data, int n) { memset(data, 0, sizeof(ll) * n); }
void zero(unsigned long long* data, int n) { memset(data, 0, sizeof(unsigned long long) * n); }
void zero(char* data, int n) { memset(data, 0, sizeof(char) * n); }
char readc() { char var; fscanf(_fin, "%c", &var); return var; }
int readi() { int var; fscanf(_fin, "%d", &var); return var; }
double readlf() { double var; fscanf(_fin, "%lf", &var); return var; }
ll readll() { ll var; fscanf(_fin, "%lld", &var); return var; }
void repread(int* data, int n) { repi(n) data[i] = readi(); }
void repread(ll* data, int n) { repi(n) data[i] = readll(); }
int reads(char* str, int maxsize)
{
	for (;;) { if (fgets(str, maxsize, _fin) == NULL) break; if (str[0] != '\n' && str[0] != '\r') break; }
	int slen = strlen(str); if (slen == 0) return 0;
	if (str[slen - 1] == '\n' || str[slen - 1] == '\r') str[--slen] = 0;
	return slen;
}

#define writec(var) fprintf(_fout,"%c",var)
#define writecsp(var) fprintf(_fout,"%c ",var)
#define writecln(var) fprintf(_fout,"%c\n",var)
#define writei(var) fprintf(_fout,"%d",var)
#define writeisp(var) fprintf(_fout,"%d ",var)
#define writellsp(var) fprintf(_fout,"%lld ",var)
#define writeiln(var) fprintf(_fout,"%d\n",var)
#define writellln(var) fprintf(_fout,"%lld\n",var)
#define writeulln(var) fprintf(_fout,"%llu\n",var)
#define writefln(var) fprintf(_fout,"%f\n",var)
#define writes(str) fprintf(_fout,"%s",str)
#define writesp() fprintf(_fout," ")
#define writeln() fprintf(_fout,"\n")
#define RUN_LOCAL(testfilename) {_fin = fopen(testfilename, "r"); if(_fin==NULL) _fin=stdin;}
#define swap(type,a, b) {type t=a;a=b;b=t;}
#define sort(data,n) std::sort(data,data+n)
//#define mod(a,b) b==0 ? 0 : a==0 ? 0 :(a>0 ? a%b : b + a % b) //what the hell is this...
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return (a / g) * b; }
void reverse(char* data, int n) { int k = n >> 1; repi(k) { char tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }
void reverse(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }
void reverse(ll* data, int n) { int k = n >> 1; repi(k) { ll tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }

#define _Vec(type, name) \
struct name { type* data; int size; int n; };\
void init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\
void resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\
void add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\
void free(name* t) { free(t->data);}
_Vec(int, Veci)
_Vec(long long, Vecll)
_Vec(char*, Vecs)

#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}
_ispal(int, ispali)
_ispal(char, ispalc)

#define _Pair(type, name) struct name{type x, y;}; \
int cmp_##name(const void* _a, const void* _b)\
{\
	name* a = (name*)_a;name* b = (name*)_b;\
	if (a->x < b->x) return -1;\
	else\
	{\
		if (a->x == b->x)\
		{\
			if (a->y == b->y) return 0;\
			if (a->y < b->y) return -1;\
			else return 1;\
		}\
		else\
		{\
			return 1;\
		}\
	}\
}\
void sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}
	_Pair(int, Pairi)
	_Pair(double,Pairlf)

	int cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }
void sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }

ll expmod(ll x, ll n, ll m) {
	ll ans = 1;
	for (; n;) {
		if (n & 1) ans = (ans * x) % m;
		x = (x * x) % m;
		n >>= 1;
	}
	return ans;
}

ll combmod(ll n, ll k, ll m) {
	ll ret = 1;
	ll div = 1;
	for (ll i = 0; i < k; ++i) {
		ret = (ret * (n - i) % m) % m;
		div = (div * (i + 1)) % m;
	}
	div = expmod(div, m - 2, m) % m;
	return (ret * div) % m;
}

int next_perm(int* data, int n)
{
	//find first i,i+1 where d[i]<d[i+1]
	int rootidx = -1;
	for (int i = n - 2; i >= 0; --i)
	{
		if (data[i] < data[i + 1])
		{
			rootidx = i;
			break;
		}
	}

	if (rootidx == -1) return 0;

	int ceilingidx = rootidx + 1;
	//find smallest d[x] after d[rooti] where d[x]>d[rooti]
	for (int i = rootidx + 2; i < n; ++i)
	{
		if (data[i] > data[rootidx] && data[i] < data[ceilingidx])
		{
			ceilingidx = i;
		}
	}

	swap(int, data[rootidx], data[ceilingidx]);
	sort(&data[rootidx + 1], n - rootidx - 1);
	return 1;
}
int count_digits(ll a)
{
	int k = 0;
	for (;;)
	{
		if (a == 0)break;
		k++;
		a /= 10;
	}
	return k;
}

/*
use only when val EXISTS in data
*/
int bs_exists(int* data, int n, int val)
{
	int left = 0;
	int right = n - 1;
	for (; left < right;)
	{
		int mid = (left + right + 1) >> 1;
		if (data[mid] <= val) left = mid;
		else right = mid - 1;
	}
	return right;
}

ll simple_factorial(int x)
{
	ll f = 1.0;
	repi(x)
	{
		f *= (i + 1);
	}
	return f;
}

unsigned long long djb2(char* data, int n)
{
	unsigned long long h = 5381;
	for (int i = 0; i < n; ++i) h = (h << 5) + h + data[i];
	return h;
}

struct Hashcount
{
	int* count;
	unsigned long long* keys;
	int size_bits;
};
void init(Hashcount* h, int size_bits)
{
	h->size_bits = size_bits;
	int size = 1 << h->size_bits;
	h->count = (int*)malloc(sizeof(int) * size);
	zero(h->count, size);
	h->keys = (unsigned long long*)malloc(sizeof(unsigned long long) * size);
	zero(h->keys, size);
}

int set(Hashcount* h, unsigned long long key)
{
	//knuth's golden ratio multiplicative hashing for 64-bit keys
	int index = (key * 2654435761) >> (64 - h->size_bits);
	int size = 1 << h->size_bits;
	for (int i = 0; i < size; i++)
	{
		if (h->keys[index] == key) //if key exists, overwrite data
		{
			h->count[index]++;
			return index;
		}

		if (h->keys[index] == 0) //empty spot
		{
			h->count[index] = 1;
			h->keys[index] = key;
			return index;
		}

		index++;
		index &= size - 1;
	}

	return -1;//return invalid index if data was not placed. this could be used as an indicator to resize.
}

int get(Hashcount* h, unsigned long long key)
{
	int index = (key * 2654435761) >> (64 - h->size_bits);
	int size = 1 << h->size_bits;
	for (int i = 0; i < size; i++)
	{
		if (h->keys[index] == key)//found original key
		{
			return h->count[index];
		}

		if (h->keys[index] == 0) return 0;//if you see a zero,key was never there

		index++;
		index &= size - 1;
	}
	return 0;
}
//not sure if this works
int sub(Hashcount* h, unsigned long long key)
{
	int index = (key * 2654435761) >> (64 - h->size_bits);
	int size = 1 << h->size_bits;
	for (int i = 0; i < size; i++)
	{
		if (h->keys[index] == key)//found original key
		{
			--h->count[index];
			if (h->count[index] < 0) h->count[index] = 0;
			return h->count[index];
		}

		if (h->keys[index] == 0) return 0;//if you see a zero,key was never there

		index++;
		index &= size - 1;
	}
	return 0;
}

const ll MOD  = 1e9 + 7;
/*
//proper binary search???
//tested on 1 problem it works!!!!!!!
int left = 0;
int right = n-1;
for (;;)
{
	if (left >= right)break;
	int mid = (left + right) >> 1;
	if (x <= a[mid]) right = mid;
	else left = mid+1;
}

printf("%d %d\n",right, a[right]);
*/

//------------------------------------------

//------------

int main()
{

	RUN_LOCAL("input.txt");
	int t = readi();

	rep(_t,t)
	{
		int a = readi();
		int b = readi();
		int x = readi();
		int y = readi();
		int n = readi();

		ll ansa = 0;
		{
			int _a = a; int _b = b;
			int m = n;
			int suba = _min(m, _a - x);
			m -= suba;
			_a -= suba;
			int subb = _min(m, b - y);
			_b -= subb;
			ansa = (ll)_a * (ll)_b;
		}
		ll ansb = 0;
		{
			int _a = a; int _b = b;
			int m = n;
			int subb = _min(m, _b - y);
			_b -= subb;
			m -= subb;
			int suba = _min(m, _a - x);
			_a -= suba;
			ansb = (ll)_a * (ll)_b;
		}
		printf("%lld\n", _min(ansa, ansb));
	}

	return 0;
}


/*
URL_HERE
*/
/*

*/
#ifdef _WIN32
#pragma warning(disable:4996)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <queue>
#include <iostream>
using namespace std;

FILE* _fin = stdin;
FILE* _fout = stdout;
#define PI 3.141592653589793238462643383279502884197169399375105820974
#define ten5p1 100001
#define ten6p1 1000001
#define ten8p1 100000001
#define ten9p1 1000000001
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define rep(var,n) for(int var=0;var<n;++var)
#define repi(n) rep(i,n)
#define repj(n) rep(j,n)
#define repi1(n) for(int i=1;i<n;++i)
#define repj1(n) for(int j=1;j<n;++j)
int _min(int a, int b) { return a <= b ? a : b; }
ll _min(ll a, ll b) { return a <= b ? a : b; }
int _max(int a, int b) { return a >= b ? a : b; }
ll _max(ll a, ll b) { return a >= b ? a : b; }
void zero(int* data, int n) { memset(data, 0, sizeof(int) * n); }
void zero(ll* data, int n) { memset(data, 0, sizeof(ll) * n); }
void zero(unsigned long long* data, int n) { memset(data, 0, sizeof(unsigned long long) * n); }
void zero(char* data, int n) { memset(data, 0, sizeof(char) * n); }
char readc() { char var; fscanf(_fin, "%c", &var); return var; }
int readi() { int var; fscanf(_fin, "%d", &var); return var; }
double readlf() { double var; fscanf(_fin, "%lf", &var); return var; }
ll readll() { ll var; fscanf(_fin, "%lld", &var); return var; }
void repread(int* data, int n) { repi(n) data[i] = readi(); }
void repread(ll* data, int n) { repi(n) data[i] = readll(); }
int reads(char* str, int maxsize)
{
	for (;;) { if (fgets(str, maxsize, _fin) == NULL) break; if (str[0] != '\n' && str[0] != '\r') break; }
	int slen = strlen(str); if (slen == 0) return 0;
	if (str[slen - 1] == '\n' || str[slen - 1] == '\r') str[--slen] = 0;
	return slen;
}

#define writec(var) fprintf(_fout,"%c",var)
#define writecsp(var) fprintf(_fout,"%c ",var)
#define writecln(var) fprintf(_fout,"%c\n",var)
#define writei(var) fprintf(_fout,"%d",var)
#define writeisp(var) fprintf(_fout,"%d ",var)
#define writellsp(var) fprintf(_fout,"%lld ",var)
#define writeiln(var) fprintf(_fout,"%d\n",var)
#define writellln(var) fprintf(_fout,"%lld\n",var)
#define writeulln(var) fprintf(_fout,"%llu\n",var)
#define writefln(var) fprintf(_fout,"%f\n",var)
#define writes(str) fprintf(_fout,"%s",str)
#define writesp() fprintf(_fout," ")
#define writeln() fprintf(_fout,"\n")
#define RUN_LOCAL(testfilename) {_fin = fopen(testfilename, "r"); if(_fin==NULL) _fin=stdin;}
#define swap(type,a, b) {type t=a;a=b;b=t;}
#define sort(data,n) std::sort(data,data+n)
//#define mod(a,b) b==0 ? 0 : a==0 ? 0 :(a>0 ? a%b : b + a % b) //what the hell is this...
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return (a / g) * b; }
void reverse(char* data, int n) { int k = n >> 1; repi(k) { char tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }
void reverse(int* data, int n) { int k = n >> 1; repi(k) { int tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }
void reverse(ll* data, int n) { int k = n >> 1; repi(k) { ll tmp = data[i]; data[i] = data[n - i - 1]; data[n - i - 1] = tmp; } }

#define _Vec(type, name) \
struct name { type* data; int size; int n; };\
void init(name* t, int size) { t->data = (type*)malloc(sizeof(type) * size); t->size = size; t->n = 0; }\
void resize(name* t) { int ns = t->size * 1.2f; t->data = (type*)realloc(t->data, sizeof(type) * ns); t->size = ns; }\
void add(name* t, type val) { if (t->n >= t->size) resize(t); int k = t->n; t->data[k] = val; t->n = k + 1; }\
void free(name* t) { free(t->data);}
_Vec(int, Veci)
_Vec(long long, Vecll)
_Vec(char*, Vecs)

#define _ispal(type, name) int name(type* a, type* b, int n){repi(n){if (a[i] != b[n - i - 1]){return 0;}}return 1;}
_ispal(int, ispali)
_ispal(char, ispalc)

#define _Pair(type, name) struct name{type x, y;}; \
int cmp_##name(const void* _a, const void* _b)\
{\
	name* a = (name*)_a;name* b = (name*)_b;\
	if (a->x < b->x) return -1;\
	else\
	{\
		if (a->x == b->x)\
		{\
			if (a->y == b->y) return 0;\
			if (a->y < b->y) return -1;\
			else return 1;\
		}\
		else\
		{\
			return 1;\
		}\
	}\
}\
void sort_##name(name* d, int n){qsort(d, n, sizeof(name), cmp_##name);}
	_Pair(int, Pairi)
	_Pair(double,Pairlf)

	int cmp_Str(const void* _a, const void* _b) { char* a = *((char**)_a); char* b = *((char**)_b); return strcmp(a, b); }
void sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }

ll expmod(ll x, ll n, ll m) {
	ll ans = 1;
	for (; n;) {
		if (n & 1) ans = (ans * x) % m;
		x = (x * x) % m;
		n >>= 1;
	}
	return ans;
}

ll combmod(ll n, ll k, ll m) {
	ll ret = 1;
	ll div = 1;
	for (ll i = 0; i < k; ++i) {
		ret = (ret * (n - i) % m) % m;
		div = (div * (i + 1)) % m;
	}
	div = expmod(div, m - 2, m) % m;
	return (ret * div) % m;
}

int next_perm(int* data, int n)
{
	//find first i,i+1 where d[i]<d[i+1]
	int rootidx = -1;
	for (int i = n - 2; i >= 0; --i)
	{
		if (data[i] < data[i + 1])
		{
			rootidx = i;
			break;
		}
	}

	if (rootidx == -1) return 0;

	int ceilingidx = rootidx + 1;
	//find smallest d[x] after d[rooti] where d[x]>d[rooti]
	for (int i = rootidx + 2; i < n; ++i)
	{
		if (data[i] > data[rootidx] && data[i] < data[ceilingidx])
		{
			ceilingidx = i;
		}
	}

	swap(int, data[rootidx], data[ceilingidx]);
	sort(&data[rootidx + 1], n - rootidx - 1);
	return 1;
}
int count_digits(ll a)
{
	int k = 0;
	for (;;)
	{
		if (a == 0)break;
		k++;
		a /= 10;
	}
	return k;
}

/*
use only when val EXISTS in data
*/
int bs_exists(int* data, int n, int val)
{
	int left = 0;
	int right = n - 1;
	for (; left < right;)
	{
		int mid = (left + right + 1) >> 1;
		if (data[mid] <= val) left = mid;
		else right = mid - 1;
	}
	return right;
}

ll simple_factorial(int x)
{
	ll f = 1.0;
	repi(x)
	{
		f *= (i + 1);
	}
	return f;
}

unsigned long long djb2(char* data, int n)
{
	unsigned long long h = 5381;
	for (int i = 0; i < n; ++i) h = (h << 5) + h + data[i];
	return h;
}

struct Hashcount
{
	int* count;
	unsigned long long* keys;
	int size_bits;
};
void init(Hashcount* h, int size_bits)
{
	h->size_bits = size_bits;
	int size = 1 << h->size_bits;
	h->count = (int*)malloc(sizeof(int) * size);
	zero(h->count, size);
	h->keys = (unsigned long long*)malloc(sizeof(unsigned long long) * size);
	zero(h->keys, size);
}

int set(Hashcount* h, unsigned long long key)
{
	//knuth's golden ratio multiplicative hashing for 64-bit keys
	int index = (key * 2654435761) >> (64 - h->size_bits);
	int size = 1 << h->size_bits;
	for (int i = 0; i < size; i++)
	{
		if (h->keys[index] == key) //if key exists, overwrite data
		{
			h->count[index]++;
			return index;
		}

		if (h->keys[index] == 0) //empty spot
		{
			h->count[index] = 1;
			h->keys[index] = key;
			return index;
		}

		index++;
		index &= size - 1;
	}

	return -1;//return invalid index if data was not placed. this could be used as an indicator to resize.
}

int get(Hashcount* h, unsigned long long key)
{
	int index = (key * 2654435761) >> (64 - h->size_bits);
	int size = 1 << h->size_bits;
	for (int i = 0; i < size; i++)
	{
		if (h->keys[index] == key)//found original key
		{
			return h->count[index];
		}

		if (h->keys[index] == 0) return 0;//if you see a zero,key was never there

		index++;
		index &= size - 1;
	}
	return 0;
}
//not sure if this works
int sub(Hashcount* h, unsigned long long key)
{
	int index = (key * 2654435761) >> (64 - h->size_bits);
	int size = 1 << h->size_bits;
	for (int i = 0; i < size; i++)
	{
		if (h->keys[index] == key)//found original key
		{
			--h->count[index];
			if (h->count[index] < 0) h->count[index] = 0;
			return h->count[index];
		}

		if (h->keys[index] == 0) return 0;//if you see a zero,key was never there

		index++;
		index &= size - 1;
	}
	return 0;
}

const ll MOD  = 1e9 + 7;
/*
//proper binary search???
//tested on 1 problem it works!!!!!!!
int left = 0;
int right = n-1;
for (;;)
{
	if (left >= right)break;
	int mid = (left + right) >> 1;
	if (x <= a[mid]) right = mid;
	else left = mid+1;
}

printf("%d %d\n",right, a[right]);
*/

//------------------------------------------

//------------

int main()
{

	RUN_LOCAL("input.txt");
	int t = readi();

	rep(_t,t)
	{
		int a = readi();
		int b = readi();
		int x = readi();
		int y = readi();
		int n = readi();

		ll ansa = 0;
		{
			int _a = a; int _b = b;
			int m = n;
			int suba = _min(m, _a - x);
			m -= suba;
			_a -= suba;
			int subb = _min(m, b - y);
			_b -= subb;
			ansa = (ll)_a * (ll)_b;
		}
		ll ansb = 0;
		{
			int _a = a; int _b = b;
			int m = n;
			int subb = _min(m, _b - y);
			_b -= subb;
			m -= subb;
			int suba = _min(m, _a - x);
			_a -= suba;
			ansb = (ll)_a * (ll)_b;
		}
		printf("%lld\n", _min(ansa, ansb));
	}

	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;

i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);

    cin >> T;
    //T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        i64 a, b, x, y;
        cin >> a >> b >> x >> y >> n;

        i64 da = max(x, a - n);
        i64 db = max(y, b - n);

        if (da > db) {
            swap(a, b);
            swap(x, y);
            swap(da, db);
        }

        //a = da;
        n -= abs(a - da);
        if (n) {
            b = max(y, b - n);
        }

        cout << da*b << endl;

    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;

i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);

    cin >> T;
    //T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        i64 a, b, x, y;
        cin >> a >> b >> x >> y >> n;

        if (x > y) {
            swap(x, y);
            swap(a, b);
        }

        if (x == 1 && n >= abs(x-a)) {
            n -= abs(a - x);
            a = 1;
        }

        if (y == 1 && n >= abs(y - b)) {
            n -= abs(y - b);
            b = 1;
        }

        if (n) {
            if (a <= b) {
                i64 z = min(abs(a - x), n);
                a -= z;
                n -= z;

                b -= min(abs(b - y), n);
            }
            else {
                i64 z = min(abs(b - y), n);
                b -= z;
                n -= z;

                a -= min(abs(a - x), n);
            }
        }

        cout << a*b << endl;

    }
    return 0;
}


#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int main() {
	long long t;
	cin >> t;
	vector<long long>v(t);
	for (int p = 0; p < t; p++) {
		long long a, b, x, y, n,a1,b1,a2,b2,a3,b3,a4,b4,n1;
		cin >> a >> b >> x >> y >> n;
		n1 = n;
		if (a - n < x) {
			a1 = x;
			n = n - (a - x);
			if (b - n < y)
				b1 = y;
			else b1 = b - n;
		}
		else {
			a1 = a - n;
			b1 = b;
		}
		n = n1;

		if (b - n < y) {
			b2 = y;
			n = n - (b - y);
			if (a - n < x)
				a2 = x;
			else a2 = a - n;
		}
		else {
			b2 = b - n;
			a2 = a;
		}

		v[p] = min(a1 * b1, a2 * b2);
	}
	for (int i = 0; i < t; i++) {
		cout << v[i] << '\n';
	}
}


#include <algorithm>
#include <iostream>

using namespace std;

long long minimum(long long a, long long b, long long x, long long y, long long n) {
    long long min_a = max(x, (a - n));
    long long min_b = max(y, (b - n));

    if (min_a < min_b) {
        if (a - n >= x) {
            return (a - n) * b;
        }
        else {
            return x * (b - (n - (a - x)));
        }
    }
    else {
        if (b - n >= x) {
            return (b - n) * a;
        }
        else {
            return y * (a - (n - (b - y)));
        }
    }
}

int main() {
    // Makes cin run faster I think
    ios_base::sync_with_stdio(0);

    int t;
    cin >> t;

    long long a;
    long long b;
    long long x;
    long long y;
    int n;

    while (t--) {
        cin >> a >> b >> x >> y >> n;
        cout << minimum(a, b, x, y, n) << endl;
    }

    return 0;
};


#include <algorithm>
#include <iostream>

using namespace std;

long long minimum(long long a, long long b, long long x, long long y, long long n) {
    long long min_a = max(x, (a - n));
    long long min_b = max(y, (b - n));

    if (min_a < min_b) {
        if (a - n >= x) {
            return (a - n) * b;
        }
        else if (a - x + b - y > n) {
            return x * (b - (n - (a - x)));
        }
        else {
            return x * y;
        }
    }
    else {
        if (b - n >= y) {
            return (b - n) * a;
        }
        else if (a - x + b - y > n) {
            return y * (a - (n - (b - y)));
        }
        else {
            return x * y;
        }
    }
}

int main() {
    // Makes cin run faster I think
    ios_base::sync_with_stdio(0);

    int t;
    cin >> t;

    long long a;
    long long b;
    long long x;
    long long y;
    int n;

    while (t--) {
        cin >> a >> b >> x >> y >> n;
        cout << minimum(a, b, x, y, n) << endl;
    }

    return 0;
};


#include <algorithm>
#include <iostream>

using namespace std;

long long minimum(long long a, long long b, long long x, long long y, long long n) {
    long long min_a = max(x, (a - n));
    long long min_b = max(y, (b - n));

    if (min_a < min_b) {
        if (a - n >= x) {
            return (a - n) * b;
        }
        else {
            return x * (b - (n - (a - x)));
        }
    }
    else {
        if (b - n >= y) {
            return (b - n) * a;
        }
        else {
            return y * (a - (n - (b - y)));
        }
    }
}

int main() {
    // Makes cin run faster I think
    ios_base::sync_with_stdio(0);

    int t;
    cin >> t;

    long long a;
    long long b;
    long long x;
    long long y;
    int n;

    while (t--) {
        cin >> a >> b >> x >> y >> n;
        cout << minimum(a, b, x, y, n) << endl;
    }

    return 0;
};


using namespace std;

int minimum(long long a, long long b, long long x, long long y, long long n) {
    long long min_a = max(x, (a - n));
    long long min_b = max(y, (b - n));

    if (min_a < min_b) {
        if (a - n >= x) {
            return (a - n) * b;
        }
        else {
            return x * (b - (n - (a - x)));
        }
    }
    else {
        if (b - n >= x) {
            return (b - n) * a;
        }
        else {
            return y * (a - (n - (b - y)));
        }
    }
}

int main {
    // Makes cin run faster I think
    ios_base::sync_with_stdio(0);

    int t;
    cin >> t;

    long long a;
    long long b;
    long long x;
    long long y;

    while (t--) {
        cin >> a >> b >> x >> y;
        cout << minimum(a, b, x, y) << endl;
    }

    return 0;
}


#include <iostream>
//#include <sstream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int n,miny=1001,x,y,z;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++)
    {
      z=a[i+1]-a[i];
     if(z<0) z*=-1;
     if( z< miny ) {x=i+1; y=i+2; miny=z;}
     cout<<miny<<x<<y;
    }
    z=a[n-1]-a[0];
     if(z<0) z*=-1;
     if( z< miny ) {x=n; y=1;}

    cout<<x<<" "<<y<<endl;
   return 0;

}


#include<iostream> #include<math.h> using namespace std; int main(){     int n,a[1000],x,y,min;     cin>>n;     for(int i=0;i<n;i++)         cin>>a[i];     min=fabs(a[0]-a[n-1]);     x=n;y=1;     for(int i=0;i<n-1;i++){         if(fabs(a[i]-a[i+1])<min){             min=fabs(a[i]-a[i+1]);             x=i+1;             y=i+2;         }     }     cout<<x<<" "<<y;     return 0; } - See more at: http://ideone.com/psIEbU#sthash.zoQWmxwM.dpuf


#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
int Abs(int x){
    if(x<0)return -x;
    return x;
}
int main(){
    int n,a[101];
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    a[n]=a[0];
    int mn=1<<30;
    int x,y;
    for(int i=0;i<n+1;++i)
        if(Abs(a[i]-a[i+1])<mn){
            mn=Abs(a[i]-a[i+1]);
            x=i+1;
            y=i+2;
        }
    if(y>n)y=1;
    cout<<x<<" "<<y;
}


#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
int Abs(int x){
    if(x<0)return -x;
    return x;
}
int main(){
    int n,a[101];
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int mn=1<<30;
    int x,y;
    for(int i=1;i<n;++i)
        if(Abs(a[i]-a[i+1])<mn){
            mn=Abs(a[i]-a[i+1]);
            x=i;
            y=i+1;
        }
    if(Abs(a[1]-a[n])<mn){
        x=1;
        y=n;
    }
    cout<<x<<" "<<y;
}


#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
int Abs(int x){
    if(x<0)return -x;
    return x;
}
int main(){
    int n,a[101];
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    int mn=1<<30;
    int x,y;
    for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j)
            if(Abs(a[i]-a[j])<mn){
                mn=Abs(a[i]-a[j]);
                x=i;
                y=j;
            }
    cout<<x<<" "<<y;
}


#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
int Abs(int x){
	if(x<0)return -x;
	return x;
}
int main(){
	int n,a[101];
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	a[n]=a[0];
	int mn=1<<30;
	int x,y;
	for(int i=1;i<n;++i)
		if(Abs(a[i]-a[i+1])<mn){
			mn=Abs(a[i]-a[i+1]);
			x=i;
			y=i+1;
		}
	if(Abs(a[1]-a[n])<mn){
		x=1;
		y=n;
	}
	cout<<x<<" "<<y;
}


#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int n,a[1000],x,y,min;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    min=fabs(a[0]-a[n-1]);
    x=n;y=1;
    for(int i=0;i<n-1;i++){
        if(fabs(a[i]-a[i+1])<min){
            min=fabs(a[i]-a[i+1]);
            x=i+1;
            y=i+2;
        }
    }
    cout<<x<<" "<<y;
    return 0;
}


#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
int Abs(int x){
    if(x<0)return -x;
    return x;
}
int main(){
    int n,a[101];
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    int mn=1<<30;
    int x,y;
    for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j)
            if(Abs(a[i]-a[j])<mn){
                mn=Abs(a[i]-a[j]);
                x=i;
                y=j;
            }
    cout<<x+1<<" "<<y+1;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
 //freopen("a.in", "r", stdin);
 //freopen("a.out", "w", stdout);

 int n, a[101], inx, iny, Min = 100000, m1, m2;

 cin >> n;

 for(int i = 0; i < n; i++)
  cin >> a[i];

 for(int i = 0; i < n; i++)
  for(int j = 0; j < n; j++)
   if(i != j && max(a[i], a[j]) - min(a[i], a[j]) < Min)
    Min = max(a[i], a[j]) - min(a[i], a[j]), inx = i, iny = j;

 m1 = max(inx + 1, iny + 1);
 m2 = min(inx + 1, iny + 1);

 if(m1 == n)
  {
   cout << m1 << " " << m2;
   return 0;
  }

 cout << m2 << " " << m1;

 return 0;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
 freopen("a.in", "r", stdin);
 freopen("a.out", "w", stdout);

 int n, a[101], inx, iny, Min = 99999, m1, m2;

 cin >> n;

 for(int i = 0; i < n; i++)
  cin >> a[i];

 for(int i = 0; i < n - 1; i++)
  if(max(a[i], a[i + 1]) - min(a[i], a[i + 1]) < Min)
    Min = max(a[i], a[i + 1]) - min(a[i], a[i + 1]), inx = i, iny = i + 1;

 if(max(a[n - 1], a[0]) - min(a[n - 1], a[0]) < Min)
  {
   cout << n << " 1";
   return 0;
  }

 //cout << "a";

 m1 = max(inx + 1, iny + 1);
 m2 = min(inx + 1, iny + 1);

 if(m1 == n)
  {
   cout << m1 << " " << m2;
   return 0;
  }

 cout << m2 << " " << m1;

 return 0;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
 freopen("a.in", "r", stdin);
 freopen("a.out", "w", stdout);

 int n, a[101], inx, iny, Min = 100000, m1, m2;

 cin >> n;

 for(int i = 0; i < n; i++)
  cin >> a[i];

 for(int i = 0; i < n; i++)
  for(int j = 0; j < n; j++)
   if(i != j && max(a[i], a[j]) - min(a[i], a[j]) < Min)
    Min = max(a[i], a[j]) - min(a[i], a[j]), inx = i, iny = j;

 m1 = max(inx + 1, iny + 1);
 m2 = min(inx + 1, iny + 1);

 if(m1 == n)
  {
   cout << m1 << " " << m2;
   return 0;
  }

 cout << m2 << " " << m1;

 return 0;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
 //freopen("a.in", "r", stdin);
 //freopen("a.out", "w", stdout);

 int n, a[101], inx, iny, Min = 99999, m1, m2;

 cin >> n;

 for(int i = 0; i < n; i++)
  cin >> a[i];

 for(int i = 0; i < n - 1; i++)
  if(max(a[i], a[i + 1]) - min(a[i], a[i + 1]) < Min)
    Min = max(a[i], a[i + 1]) - min(a[i], a[i + 1]), inx = i, iny = i + 1;

 if(max(a[n - 1], a[0]) - min(a[n - 1], a[0]) < Min)
  {
   cout << n << " 1";
   return 0;
  }

 //cout << "a";

 m1 = max(inx + 1, iny + 1);
 m2 = min(inx + 1, iny + 1);

 if(m1 == n)
  {
   cout << m1 << " " << m2;
   return 0;
  }

 cout << m2 << " " << m1;

 return 0;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
 //freopen("a.in", "r", stdin);
 //freopen("a.out", "w", stdout);

 int n, a[101], inx, iny, Min = 99999, m1, m2;

 cin >> n;

 for(int i = 0; i < n; i++)
  cin >> a[i];

 for(int i = 0; i < n - 1; i++)
  if(max(a[i], a[i + 1]) - min(a[i], a[i + 1]) < Min)
    Min = max(a[i], a[i + 1]) - min(a[i], a[i + 1]), inx = i, iny = i + 1;

 if(max(a[n - 1], a[0]) - min(a[n - 1], a[0]) < Min)
  {
   cout << n << " 1";
   return 0;
  }

 //cout << "a";

 //m1 = max(inx + 1, iny + 1);
 //m2 = min(inx + 1, iny + 1);

 if(m1 == n)
  {
   cout << m1 << " " << m2;
   return 0;
  }

 cout << m2 << " " << m1;

 return 0;
}


#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
 //freopen("a.in", "r", stdin);
 //freopen("a.out", "w", stdout);

 int n, a[101], inx, iny, Min = 99999, m1, m2;

 cin >> n;

 for(int i = 0; i < n; i++)
  cin >> a[i];

 for(int i = 0; i < n - 1; i++)
  if(max(a[i], a[i + 1]) - min(a[i], a[i + 1]) < Min)
    Min = max(a[i], a[i + 1]) - min(a[i], a[i + 1]), inx = i, iny = i + 1;

 //cout << "a";

 m1 = max(inx + 1, iny + 1);
 m2 = min(inx + 1, iny + 1);

 if(m1 == n)
  {
   cout << m1 << " " << m2;
   return 0;
  }

 cout << m2 << " " << m1;

 return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main()
{
 int x, min1 = 1e9, min2 =1e9, l, a = 0, b = 0;
 cin >> x;
 l = x;
 int ar[x];
 while (x--){
    cin >> ar[x];
    if(min1 > ar[x]) {min1 = ar[x]; a = x + 1;}
}
while (l--){
    if (min2 > ar[l] && a - 1 != l){min2 = ar[l]; b = l + 1;}
}
cout << a << " " << b;

}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>
#include <cmath>
using namespace std;

int main()
{
 int x, min1 = 1e9, l, a = 0, b = 0;
 cin >> x;
 l = x;
 int ar[x];
 while (x--)
    cin >> ar[x];
for (int i = 0; i < l; i++){
        if (i==l-1) {if (min1 > abs(ar[4] - ar[0])){min1 = abs(ar[4] - ar[0]); a = 5; b = 1;}}
        else {if (min1 > abs(ar[i] - ar[i - 1])){min1 = abs(ar[i] - ar[i + 1]); a = i + 1; b = i+2;}}

    }
cout << a << " " << b;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main()
{
 int x;
 cin >> x;
 if (x == 5)
    cout << "1 5";
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main(){
int x, min = 1e9, l , v;
cin >> x;
int ar[x];
for (int i = 0; i < x; i++){
    cin >> ar[i];
}
for (int i = 0; i < x; i++){
    for (int j = 0; j < x; j++){
if (abs(ar[i] - ar[j]) < min && i != j){l = i; v = j; min = abs(ar[i] - ar[j]);}
}
}
cout << v + 1 << " " << l + 1 << endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>
#include <cmath>
using namespace std;

int main()
{
 int x, min1 = 1e9, l, a = 0, b = 0;
 cin >> x;
 l = x;
 int ar[x];
 while (x--)
    cin >> ar[x];
for (int i = 0; i < l; i++){
        if (i==l-1) {if (min1 > abs(ar[4] - ar[0])){min1 = abs(ar[4] - ar[0]); a = 5; b = 1;}}
        else {if (min1 > abs(ar[i] - ar[i - 1])){min1 = abs(ar[i] - ar[i + 1]); a = i + 1; b = i+2;}}
        cout << min1 << endl;
    }
cout << a << " " << b;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main(){
int x, min = 1e9, l , v;
cin >> x;
int ar[x];
for (int i = 0; i < x; i++){
    cin >> ar[i];
}
    for (int j = 0; j < x; j++){
if (j == x - 1) {if (abs(ar[x - 1] - ar[0]) < min){l = x - 1; v = 0; min = abs(ar[x - 1] - ar[0]);}}
else {if (abs(ar[j] - ar[j + 1]) < min && j != x - 1){l = j; v = j + 1; min = abs(ar[j] - ar[j + 1]);}}
}

cout << v + 1 << " " << l + 1 << endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main(){
int x, min = 1e9 , c , b ;
cin >> x;
int h = x;
int ar[x];
while (x--) cin >> ar[x];
for (int i = 0; i< h; i++)
if (i == 5)if (abs(ar[x - 1] - ar[0]) < min) {min = abs(ar[x-1] - ar[0]); c = 5; b = 1;}
else if (abs(ar[i] - ar[i + 1]) < min) {min = abs(ar[i] - ar[i + 1]); c = i + 1; b = i + 2;}
cout << b << " " << c;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main(){
int x, min = 1e9, l , v;
cin >> x;
int ar[x];
for (int i = 0; i < x; i++){
    cin >> ar[i];
}
for (int i = 0; i < x; i++){
if (ar[i] < min){l = i; min = ar[i];}
}
min = 1e9;
for (int i = 0; i < x; i++){
if (ar[i] < min && i != l){v = i; min = ar[i];}
}
cout << v + 1 << " " << l + 1 << endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main(){
int x, min = 1e9 , c , b ;
cin >> x;
int h = x;
int ar[x];
while (x--) cin >> ar[x];
for (int i = 0; i< h; i++)
if (i == 5)if (abs(ar[x - 1] - ar[0]) < min) {min = abs(ar[x-1] - ar[0]); c = 5; b = 1;}
else {if (abs(ar[i] - ar[i + 1]) < min) {min = abs(ar[i] - ar[i + 1]); c = i + 1; b = i + 2;}}
cout << b << " " << c;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main()
{
 int x, min1 = 1e9, l, a = 0, b = 0;
 cin >> x;
 l = x;
 int ar[x];
 while (x--)
    cin >> ar[x];

for (int i = 0; i < l; i++){
    for (int j = 0; j < l; j++){
        if (min1 > abs(ar[i] - ar[j]) && i != j){min1 = abs(ar[i] - ar[j]); b = i + 1; a = j + 1;}
    }
}
cout << a << " " << b;

}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>
#include <cmath>
using namespace std;

int main()
{
int x;
map <int , int > a;
cin >> x;
int ar[x];
for (int i = 0; i < x; i++)
{
cin >> ar[i];
if (a[ar[i]] > 0){ar[i]--; a[ar[i]] = i + 1;}
a[ar[i]] = i + 1;
}
sort(ar , ar + x);
cout << a[ar[0]] << " " << a[ar[1]];
}


#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <ctype.h>
#include <cmath>
using namespace std;

int main()
{
 int x, min1 = 1e9, l, a = 0, b = 0;
 cin >> x;
 l = x;
 int ar[x];
 while (x--)
    cin >> ar[x];
for (int i = 0; i < l - 1; i++){
        if (min1 > abs(ar[i] - ar[i + 1])){min1 = abs(ar[i] - ar[i + 1]); a = i - 1; b = i;}
    }
cout << a << " " << b;
}


#include<iostream>
#include<cmath>
using namespace std;
int a[105];
int main()
{
	int n,minn;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	a[n+1]=a[1];
	minn=abs(a[2]-a[1]);
	int st=1;
	for(int i=2;i<=n;i++)
	{
		if(abs(a[i+1]-a[i])<minn)
		{
			minn=abs(a[i+1]-a[i]);
			st=i;
		}
	}
	if(st==n)
	cout<<st<<" 1"<<endl;
	if(st!=n)
	cout<<st<<" "<<st+1<<endl;
	return 0;
 }


#include <iostream>
#include <cmath>
using namespace std;
int s[110];
int main()
{
	int n;
	cin>>n;
	int i;
	int temp=1000;
	int index;
	for(i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	for(i=1;i<=n;i++)
	{
		if(i<n)
		{
			if(fabs(s[i+1]-s[i])<temp)
		  {
			 index=i;
			 temp=fabs(s[i+1]-s[i]);
		  }
		}
		else
		{
			if(fabs(s[1]-s[n])<temp)
			  {
			  	temp=fabs(s[1]-s[n]);
			  	index=i;
			  }
		}
	}
	if(index==n)
	{
		printf("%d 1\n",n);
	}
	else
	{
		printf("%d %d\n",index,index+1);
	}
	return 0;
 }


#include<stdio.h>
#include<math.h>
int main(){
	int n,i;
	while(~scanf("%d",&n)){
		int a[n+1],result,min=1000;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		a[n]=a[0];
		for(i=1;i<n+1;i++){
				if(fabs(a[i]-a[i-1])<=min){
					result=i;
					min=fabs(a[i]-a[i-1]);
				}
		}
		if(result==n)
			printf("%d %d\n",result,1);
		else
			printf("%d %d\n",result,result+1);
	}
}


#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    int j,m,n,i;
    int h[105];
    int flag[105];
    while(cin>>n){
        for(i=1;i<=n;i++){
            cin>>h[i];
        }
        for(i=1;i<n;i++){
            flag[i]=abs(h[i]-h[i+1]);
        }
        flag[n]=abs(h[n]-h[1]);
        for(i=1;i<=n;i++){
            cout<<flag[i]<<" ";
        }
        cout<<endl;
        int flagmin=1;
        int min=flag[1];
        for(i=1;i<n;i++){
            if(min>flag[i+1])
            {
                flagmin=i+1;
                min=flag[i+1];
            }
        }
        if(min+1<=n) cout<<flagmin<<" "<<flagmin+1<<endl;
        else cout<<min<<" 1"<<endl;
    }

    return 0;
}


#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    int j,m,n,i;
    int h[105];
    int flag[105];
    while(cin>>n){
        for(i=1;i<=n;i++){
            cin>>h[i];
        }
        for(i=1;i<n;i++){
            flag[i]=abs(h[i]-h[i+1]);
        }
        flag[n]=abs(h[n]-h[1]);
        int min=1;
        for(i=1;i<n;i++){
            if(flag[i]>flag[i+1])
                min=i+1;
        }
        cout<<min<<" "<<(min+1)%n<<endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

#define Max 110

int main()
{
    int numberofpeople;
    int h[Max];
    scanf("%d", &numberofpeople);
    for(int i(0); i<numberofpeople; i++){
        scanf("%d", &h[i]);
    }
    h[numberofpeople] = h[0];
    int Min(1010);
    int ans(0);
    for(int i(0); i<numberofpeople; i++){
        if(Min > abs(h[i]-h[i+1])){
                Min = abs(h[i]-h[i-1]);
            ans = i;
        }
    }
    printf("%d ", ans+1);
    if(ans == numberofpeople-1) printf("1\n");
    else printf("%d\n", ans+2);
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;
int main() {
	int n,soldiers[105];
	while (cin >> n) {
		int min = 9999,flag=0;
		for (int i = 0;i < n;i++)cin >> soldiers[i];
		for (int i = 0;i < n;i++) {
			if (min > abs(soldiers[i%n] - soldiers[(i + 1) % n])) {
				min = abs(soldiers[i%n] - soldiers[(i + 1) % n]);
				flag = i;
			}
		}
		cout << flag%n + 1 << " " << (flag + 1) % n + 1 << endl;
	}
	return 0;
}


#include <cstdlib>
#include <cstdio>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int n,arr[101]= {0};
    while(cin>>n)
    {
        int i,j,mix=10000,index1,index2;
        for(i=0; i<n; i++)
        {
            cin>>arr[i];
        }
        for(i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
            {
                if((fabs(arr[j]-arr[i])<mix)&&(j!=i))
                {
                    index1=i+1;
                    index2=j+1;
                    mix=fabs(arr[j]-arr[i]);
                }
            }
        }
        if(index1==1 && index2==n)
            cout<<index2<<" "<<index1<<endl;
        else
            cout<<index1<<" "<<index2<<endl;
    }
    return 0;
}


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

int main()
{
    int n,t;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t);
        vec.push_back(t);
    }
    int result=1000;
    int k,p;
    for(int i=0;i<n-1;i++)
    {
        if(labs(vec[i]-vec[i+1])<result)
        {
            result=labs(vec[i]-vec[i+1]);
            k=i+1;
            p=i+2;
        }
    }
    if(labs(vec[n-1]-vec[0])<result)
        k=1,p=n;
    printf("%d %d\n",k,p);
    return 0;
}


#include <iostream>
#include <queue>
#include <cmath>
using namespace std;
int main()
{
    int n, first, ahead, after;
    int dis = 2000;
    int index1 = -1, index2 = -1, i = 1;
    cin >> n;
    cin >> first;
    ahead = first;
    n--;

    while(n--){
        cin >> after;
        if(dis > abs(after-ahead)){
            index1 = i;
            index2 = i+1;
            dis = abs(after-ahead);
        }
        ahead = after;
        ++i;
    }
   if(dis > abs(after - first)){
        index1 = i;
        index2 = 1;
   }
    cout << index1 <<' '<< index2;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int n,shu[105];
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>shu[i];
    int mins,a=1,b=2;
    mins=abs(shu[1]-shu[0]);
    for(int i=1;i<=n;i++)
        if(abs(shu[i+1]-shu[i])<mins)
        {
            mins=abs(shu[i+1]-shu[i]);
            a=i;
            b=i+1;
        }
    if(abs(shu[n]-shu[1]<mins))
    {
        a=n;
        b=1;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int a[101],b[101],c[101];

int main(){
  int n,mi=10000,minn=10000,m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    c[i]=a[i]+a[(i+1)%n];
    b[i]=a[i]-a[(i+1)%n];
    if(b[i]<0){
      b[i]*=(-1);}
    mi=min(mi,b[i]);
    minn=min(minn,c[i]);
  }
  for(int i=0;i<n;i++){
    if(b[i]==mi && c[i]==minn){
      m=i;}
  }
  cout<<m+1<<' '<<(m+2)%n<<endl;
  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int a[101],b[101],c[101];

int main(){
  int n,mi=10000,minn=10000,m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    c[i]=a[i]+a[(i+1)%n];
    b[i]=a[i]-a[(i+1)%n];
    if(b[i]<0){
      b[i]*=(-1);}
    mi=min(mi,b[i]);
    minn=min(minn,c[i]);
  }
  for(int i=0;i<n;i++){
    if(b[i]==mi && c[i]==minn){
      m=i;}
  }
  cout<<(m+1)%n<<' '<<(m+2)%n<<endl;
  return 0;
}


#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int a[200], b[200], c[200], d[200];

int main(){
  int n, m=10000, mi=10000, p;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    b[i] = fabs(a[i] - a[(i + 1) % n]);
    c[i] = a[i] + a[(i + 1) % n];
    m = min(m,b[i]);
    mi = min(mi,c[i]);
  }
  for(int i = 0; i < n; i++){
    if(b[i] == m){
      d[i] = c[i];
    }
  }
  for(int i = 0; i < n; i++){
    if(d[i] == mi){
      p = i;
    }
  }
  cout << p << ' ' << (p+1)%n;
  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

long long a[101],b[101],c[101];

int main(){
  long long n,mi=10000,minn=10000,m;
  cin>>n;
  for(long long i=0;i<n;i++){
    cin>>a[i];
  }
  for(long long i=0;i<n;i++){
    c[i]=a[i]+a[(i+1)%n];
    b[i]=a[i]-a[(i+1)%n];
    if(b[i]<0){
      b[i]*=(-1);}
    mi=min(mi,b[i]);
    minn=min(minn,c[i]);
  }
  for(long long i=0;i<n;i++){
    if(b[i]==mi && c[i]==minn){
      m=i;}
  }
  cout<<m+1<<' '<<(m+2)%n<<endl;
  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int a[201],b[201],c[201];

int main(){
  int n,mi=10000,minn=10000,m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    c[i]=a[i]+a[(i+1)%n];
    b[i]=a[i]-a[(i+1)%n];
    if(b[i]<0){
      b[i]*=(-1);}
    mi=min(mi,b[i]);
    minn=min(minn,c[i]);
  }
  for(int i=0;i<n;i++){
    if(b[i]==mi && c[i]==minn){
      m=i;}
  }
  cout<<m+1<<' '<<(m+2)%n<<endl;
  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int a[101],b[101],c[101];

int main(){
  int n,mi=10000,minn=10000,m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    c[i]=a[i]+a[(i+1)%n];
    b[i]=a[i]-a[(i+1)%n];
    if(b[i]<0){
      b[i]*=(-1);}
    mi=min(mi,b[i]);
    minn=min(minn,c[i]);
  }
  for(int i=0;i<n;i++){
    if(b[i]==mi && c[i]==minn){
      m=i;
      break;
      }
  }
  cout<<m+1<<' '<<(m+2)%n<<endl;
  return 0;
}


#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int a[200], b[200], c[200], d[200];

int main(){
  int n, m=10000, mi=10000, p;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    b[i] = fabs(a[i] - a[(i + 1) % n]);
    c[i] = a[i] + a[(i + 1) % n];
    m = min(m,b[i]);
    mi = min(mi,c[i]);
  }
  for(int i = 0; i < n; i++){
    if(b[i] == m){
      d[i] = c[i];
    }
  }
  for(int i = 0; i < n; i++){
    if(d[i] == mi){
      p = i;
    }
  }
  cout << p+1 << ' ' << (p+2)%n;
  return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    int a[n];
    cin >> n;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a[i] = x;
    }
    int max = -1,index = 0;
    for(int i = 0;i<n-1;i++){
        if(abs(a[i] - a[i-1]) < max || max == -1){
            max = abs(a[i]-a[i-1]);
            index = i;
        }
    }
    if (abs(a[0] - a[n-1]) < max)cout << 1 << ' ' << n;
    else cout << index+1 << ' ' << index+2;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    vector <int> a(n);
    cin >> n;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a[i] = x;
    }
    int max = -1,index = 0;
    for(int i = 0;i<n-1;i++){
        if(abs(a[i] - a[i+1]) < max || max == -1){
            max = abs(a[i]-a[i+1]);
            index = i;
        }
    }
    if (abs(a[0] - a[n-1]) < max)cout << 1 << ' ' << n;
    else cout << index+1 << ' ' << index+2;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#define FOR(i,n) for(int i =0;i<n;i++)
using namespace std;
int main()
{
    int n;
    vector <int> a(n);
    cin >> n;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a[i] = x;
    }
    int max = -1,index = 0;
    for(int i = 0;i<n-1;i++){
        if(abs(a[i] - a[i+1]) < max || max == -1){
            max = abs(a[i]-a[i+1]);
            cout << max << endl;
            index = i;
        }
    }
    if (abs(a[0] - a[n-1]) < max)cout << 1 << ' ' << n;
    else cout << index+1 << ' ' << index+2;
}