#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
int T1, T2, Final , At, CT1, CT2, CT3, CT, total, test, a[5], i, t;
scanf("%d", &test);
for(t=1; t<=test; t++)
{
scanf("%d%d%d%d", &T1, &T2, &Final, &At);
for(i=0; i<3; i++)
{
scanf("%d", &a[i]);
}
sort(a, a+i);
CT = a[1]+a[2];
total = (T1+T2+Final+At+CT/2);
if(total>=90)
{
printf("Case %d: A\n",t);
}
else if(total>=80 && total<90)
{
printf("Case %d: B\n", t);
}
else if(total>=70 && total<80)
{
printf("Case %d: C\n", t);
}
else if(total>=60 && total<70)
{
printf("Case %d: D\n", t);
}
else if(total<60)
{
printf("Case %d: F\n", t);
}
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
int T1, T2, Final , At, CT1, CT2, CT3, CT, total, test, a[5], i, t;
scanf("%d", &test);
for(t=1; t<=test; t++)
{
scanf("%d%d%d%d", &T1, &T2, &Final, &At);
for(i=0; i<3; i++)
{
scanf("%d", &a[i]);
}
sort(a, a+i);
CT = a[1]+a[2];
total = (T1+T2+Final+At+CT/2);
if(total>=90)
{
printf("Case %d: A\n",t);
}
else if(total>=80 && total<90)
{
printf("Case %d: B\n", t);
}
else if(total>=70 && total<80)
{
printf("Case %d: C\n", t);
}
else if(total>=60 && total<70)
{
printf("Case %d: D\n", t);
}
else if(total<60)
{
printf("Case %d: F\n", t);
}
}
return 0;
}