#include #include #include #include using namespace std; int main() { int T; int io = 1; scanf("%d", &T); while (T--) { int w1, w2, w3, w4; int x1, x2, x3, x4; int q1, q2, q3, q4; scanf("%d%d", &x1, &q1); scanf("%d%d", &x2, &q2); scanf("%d%d", &x3, &q3); scanf("%d%d", &x4, &q4); w1 = (250 - x1) * 1000 / 250 - 50 * q1; w2 = (250 - x2) * 1500 / 250 - 50 * q2; w3 = (250 - x3) * 2000 / 250 - 50 * q3; w4 = (250 - x4) * 2500 / 250 - 50 * q4; //printf("%d %d %d %d\n", w1, w2, w3, w4); if (w1<1000 * 40 / 100) w1 = 1000 * 40 / 100; if (w2<1500 * 40 / 100) w2 = 1500 * 40 / 100; if (w3<2000 * 40 / 100) w3 = 2000 * 40 / 100; if (w4<2500 * 40 / 100) w4 = 2500 * 40 / 100; printf("Case #%d: %d\n", io++, w1 + w2 + w3 + w4); } return 0; }